lib/socket/SocketNamespace.js
function SocketNamespace() {
  var self = this;
  var namespace = null;

  Object.defineProperties(this, {

    /**
     * The list of messages' handlers.
     *
     * @property handlers
     * @type Object
     */
    handlers: {value: {}},

    /**
     * The list of middlewares.
     *
     * @property middlewares
     * @type Array
     */
    middlewares: {value: []},

    /**
     * The socket namespace.
     *
     * @property namespace
     * @type Namespace
     */
    namespace: {
      get: function() {
        return namespace;
      },
      set: function(newNamespace) {
        namespace = newNamespace;

        mountHandlers.call(self);
        mountMiddlewares.call(self);
      }
    }

  });
}
function SocketNamespace() {
  var self = this;
  var namespace = null;

  Object.defineProperties(this, {

    /**
     * The list of messages' handlers.
     *
     * @property handlers
     * @type Object
     */
    handlers: {value: {}},

    /**
     * The list of middlewares.
     *
     * @property middlewares
     * @type Array
     */
    middlewares: {value: []},

    /**
     * The socket namespace.
     *
     * @property namespace
     * @type Namespace
     */
    namespace: {
      get: function() {
        return namespace;
      },
      set: function(newNamespace) {
        namespace = newNamespace;

        mountHandlers.call(self);
        mountMiddlewares.call(self);
      }
    }

  });
}
function SocketNamespace ( ) { var self = this ; var namespace = null ; Object . defineProperties ( this , { /**
     * The list of messages' handlers.
     *
     * @property handlers
     * @type Object
     */ handlers : { value : { } } , /**
     * The list of middlewares.
     *
     * @property middlewares
     * @type Array
     */ middlewares : { value : [ ] } , /**
     * The socket namespace.
     *
     * @property namespace
     * @type Namespace
     */ namespace : { get : function ( ) { return namespace ; } , set : function ( newNamespace ) { namespace = newNamespace ; mountHandlers . call ( self ) ; mountMiddlewares . call ( self ) ; } } } ) ; }
Defines socket.io namespace wrapper.

SocketNamespace wraps a socket.io namespace to be able to connect the namespace to the server after
adding handlers to it.
Creating a Namespace using socket.io can't be done without creating the server
and attaching the namespace to it.

var openVeoApi = require('@openveo/api');
var namespace = new openVeoApi.socket.SocketNamespace();
var server = new openVeoApi.socket.SocketServer();

// Add a middleware
namespace.use(function(socket, next) {
console.log('Called for every message');
});

// Listen to a message
namespace.on('test.message', function(data) {
console.log('test.message received');
console.log(data);
});

// Add namespace to server
server.addNamespace('/myName', namespace);

// Start server
server.listen(80, function() {
console.log('Socket server started');
namespace.emit('test.message', 'some data');
});

@class SocketNamespace
@constructor
Defines socket . io namespace wrapper .