lib/connectors/hybrid/switcher.js
function(server, opts) {
  EventEmitter.call(this);
  this.server = server;
  this.wsprocessor = new WSProcessor();
  this.tcpprocessor = new TCPProcessor(opts.closeMethod);
  this.id = 1;
  this.timeout = (opts.timeout || DEFAULT_TIMEOUT) * 1000;
  this.setNoDelay = opts.setNoDelay;

  if (!opts.ssl) {
    this.server.on('connection', this.newSocket.bind(this));
  } else {
    this.server.on('secureConnection', this.newSocket.bind(this));
    this.server.on('clientError', function(e, tlsSo) {
      logger.warn('an ssl error occured before handshake established: ', e);
      tlsSo.destroy();
    });
  }

  this.wsprocessor.on('connection', this.emit.bind(this, 'connection'));
  this.tcpprocessor.on('connection', this.emit.bind(this, 'connection'));

  this.state = ST_STARTED;
}
function(server, opts) {
  EventEmitter.call(this);
  this.server = server;
  this.wsprocessor = new WSProcessor();
  this.tcpprocessor = new TCPProcessor(opts.closeMethod);
  this.id = 1;
  this.timeout = (opts.timeout || DEFAULT_TIMEOUT) * 1000;
  this.setNoDelay = opts.setNoDelay;

  if (!opts.ssl) {
    this.server.on('connection', this.newSocket.bind(this));
  } else {
    this.server.on('secureConnection', this.newSocket.bind(this));
    this.server.on('clientError', function(e, tlsSo) {
      logger.warn('an ssl error occured before handshake established: ', e);
      tlsSo.destroy();
    });
  }

  this.wsprocessor.on('connection', this.emit.bind(this, 'connection'));
  this.tcpprocessor.on('connection', this.emit.bind(this, 'connection'));

  this.state = ST_STARTED;
}
function ( server , opts ) { EventEmitter . call ( this ) ; this . server = server ; this . wsprocessor = new WSProcessor ( ) ; this . tcpprocessor = new TCPProcessor ( opts . closeMethod ) ; this . id = 1 ; this . timeout = ( opts . timeout || DEFAULT_TIMEOUT ) * 1000 ; this . setNoDelay = opts . setNoDelay ; if ( ! opts . ssl ) { this . server . on ( 'connection' , this . newSocket . bind ( this ) ) ; } else { this . server . on ( 'secureConnection' , this . newSocket . bind ( this ) ) ; this . server . on ( 'clientError' , function ( e , tlsSo ) { logger . warn ( 'an ssl error occured before handshake established: ' , e ) ; tlsSo . destroy ( ) ; } ) ; } this . wsprocessor . on ( 'connection' , this . emit . bind ( this , 'connection' ) ) ; this . tcpprocessor . on ( 'connection' , this . emit . bind ( this , 'connection' ) ) ; this . state = ST_STARTED ; }
Switcher for tcp and websocket protocol

@param {Object} server tcp server instance from node.js net module
Switcher for tcp and websocket protocol