lib/smartrouter.js
function (actorid, queuename, socket) {
    logger.info(util.format('Subscribing to queue. QueueName=%s; Socket=%s', queuename, socket.id));
    var self = this;
    self.amqp.queue(queuename, { autoDelete: false, closeChannelOnUnsubscribe: true,
                                 arguments: { 'x-expires': self.delayBeforeDeletingInactiveQueue } }, function (q) {
      q.bind(queuename);
      q.subscribe(function (message, headers, deliveryInfo) {
        logger.debug(util.format("Emitting '%s' from queue [%s] on socket %s", message.type, queuename, socket.id));
        socket.emit(message.type, message.message);
      })
      .addCallback(function (ok) {
        socket.set('actorid', actorid, function () {
          logger.info(util.format('Queue created and actor [%s] registered. Handshaking.', actorid));
          socket.emit('hello', {});
        });
        var data = { queue: q, ctag: ok.consumerTag };
        logger.debug(util.format('Registering consumerTag [%s] for queue [%s] in socket %s', ok.consumerTag, queuename, socket.id));
        socket.get('queueData', function (err, queueData) {
          queueData = queueData || [];
          queueData.push(data);
          socket.set('queueData',queueData);
        });
      });
    });

    if (this.amqp.channelCounter >= self.MAX_CHANNEL_PER_CONNECTION && !self.creatingAmqpConnection) {
      self._createAmqpConnection();
    }
  }
function (actorid, queuename, socket) {
    logger.info(util.format('Subscribing to queue. QueueName=%s; Socket=%s', queuename, socket.id));
    var self = this;
    self.amqp.queue(queuename, { autoDelete: false, closeChannelOnUnsubscribe: true,
                                 arguments: { 'x-expires': self.delayBeforeDeletingInactiveQueue } }, function (q) {
      q.bind(queuename);
      q.subscribe(function (message, headers, deliveryInfo) {
        logger.debug(util.format("Emitting '%s' from queue [%s] on socket %s", message.type, queuename, socket.id));
        socket.emit(message.type, message.message);
      })
      .addCallback(function (ok) {
        socket.set('actorid', actorid, function () {
          logger.info(util.format('Queue created and actor [%s] registered. Handshaking.', actorid));
          socket.emit('hello', {});
        });
        var data = { queue: q, ctag: ok.consumerTag };
        logger.debug(util.format('Registering consumerTag [%s] for queue [%s] in socket %s', ok.consumerTag, queuename, socket.id));
        socket.get('queueData', function (err, queueData) {
          queueData = queueData || [];
          queueData.push(data);
          socket.set('queueData',queueData);
        });
      });
    });

    if (this.amqp.channelCounter >= self.MAX_CHANNEL_PER_CONNECTION && !self.creatingAmqpConnection) {
      self._createAmqpConnection();
    }
  }
queueSubscribe: subscribe to the right queue