lib/smartrouter.js
function (endpointname, endpointid, queuebehaviour, socketep) {
    var self = this;
    socketep.on('connection', function (socket) {
      logger.info(util.format('Connection received on /%s/%s', endpointname, endpointid));
      socket.emit('whoareyou', {});
      socket.on('iam', function (actorid) {
        var endpointQueue = endpointname + '/' + endpointid;
        if (!queuebehaviour || ((queuebehaviour & QUEUEFLAG.actor) > 0)) {
          self.queueSubscribe(actorid, actorid, socket);
        }
        if ((queuebehaviour & QUEUEFLAG.endpoint) > 0) {
          self.queueSubscribe(actorid, endpointQueue, socket);
        }
      });
      socket.on('disconnect', function () {
        self.queuesUnsubscribe(socket);
      });
      self.config.routes.forEach( function (route) {
        if (route.endpoint === '*' || route.endpoint === endpointname) {
          logger.debug(util.format('Registering route [%s] for endpoint [%s]. Socket= %s', route.messagetype, route.endpoint, socket.id));
          socket.on(route.messagetype, function (message) {
            self.check(socket, route.messagetype, message, function (err, checked) {
              if (err) {
                logger.error(err);
              }
              if (checked) {
                logger.debug(util.format("Routing '%s' from [%s]. Message=%s", route.messagetype, endpointname, JSON.stringify(message)));
                route.action(message, socket, self);
              }
            });
          });
        }
      });
    });
  }
function (endpointname, endpointid, queuebehaviour, socketep) {
    var self = this;
    socketep.on('connection', function (socket) {
      logger.info(util.format('Connection received on /%s/%s', endpointname, endpointid));
      socket.emit('whoareyou', {});
      socket.on('iam', function (actorid) {
        var endpointQueue = endpointname + '/' + endpointid;
        if (!queuebehaviour || ((queuebehaviour & QUEUEFLAG.actor) > 0)) {
          self.queueSubscribe(actorid, actorid, socket);
        }
        if ((queuebehaviour & QUEUEFLAG.endpoint) > 0) {
          self.queueSubscribe(actorid, endpointQueue, socket);
        }
      });
      socket.on('disconnect', function () {
        self.queuesUnsubscribe(socket);
      });
      self.config.routes.forEach( function (route) {
        if (route.endpoint === '*' || route.endpoint === endpointname) {
          logger.debug(util.format('Registering route [%s] for endpoint [%s]. Socket= %s', route.messagetype, route.endpoint, socket.id));
          socket.on(route.messagetype, function (message) {
            self.check(socket, route.messagetype, message, function (err, checked) {
              if (err) {
                logger.error(err);
              }
              if (checked) {
                logger.debug(util.format("Routing '%s' from [%s]. Message=%s", route.messagetype, endpointname, JSON.stringify(message)));
                route.action(message, socket, self);
              }
            });
          });
        }
      });
    });
  }
registerRoutes