lib/socket.js
function Socket(sio, options) {
  if (!(this instanceof Socket)) {
    return new Socket(sio, options);
  }

  EventEmitter.call(this);

  options = options || {};

  this.sio = sio;
  this.forceBase64 = !!options.forceBase64;
  this.streams = {};
  this.encoder = new parser.Encoder();
  this.decoder = new parser.Decoder();

  var eventName = exports.event;
  sio.on(eventName, bind(this, emit));
  sio.on(eventName + '-read', bind(this, '_onread'));
  sio.on(eventName + '-write', bind(this, '_onwrite'));
  sio.on(eventName + '-end', bind(this, '_onend'));
  sio.on(eventName + '-error', bind(this, '_onerror'));
  sio.on('error', bind(this, emit, 'error'));
  sio.on('disconnect', bind(this, '_ondisconnect'));

  this.encoder.on('stream', bind(this, '_onencode'));
  this.decoder.on('stream', bind(this, '_ondecode'));
}
function Socket(sio, options) {
  if (!(this instanceof Socket)) {
    return new Socket(sio, options);
  }

  EventEmitter.call(this);

  options = options || {};

  this.sio = sio;
  this.forceBase64 = !!options.forceBase64;
  this.streams = {};
  this.encoder = new parser.Encoder();
  this.decoder = new parser.Decoder();

  var eventName = exports.event;
  sio.on(eventName, bind(this, emit));
  sio.on(eventName + '-read', bind(this, '_onread'));
  sio.on(eventName + '-write', bind(this, '_onwrite'));
  sio.on(eventName + '-end', bind(this, '_onend'));
  sio.on(eventName + '-error', bind(this, '_onerror'));
  sio.on('error', bind(this, emit, 'error'));
  sio.on('disconnect', bind(this, '_ondisconnect'));

  this.encoder.on('stream', bind(this, '_onencode'));
  this.decoder.on('stream', bind(this, '_ondecode'));
}
function Socket ( sio , options ) { if ( ! ( this instanceof Socket ) ) { return new Socket ( sio , options ) ; } EventEmitter . call ( this ) ; options = options || { } ; this . sio = sio ; this . forceBase64 = ! ! options . forceBase64 ; this . streams = { } ; this . encoder = new parser . Encoder ( ) ; this . decoder = new parser . Decoder ( ) ; var eventName = exports . event ; sio . on ( eventName , bind ( this , emit ) ) ; sio . on ( eventName + '-read' , bind ( this , '_onread' ) ) ; sio . on ( eventName + '-write' , bind ( this , '_onwrite' ) ) ; sio . on ( eventName + '-end' , bind ( this , '_onend' ) ) ; sio . on ( eventName + '-error' , bind ( this , '_onerror' ) ) ; sio . on ( 'error' , bind ( this , emit , 'error' ) ) ; sio . on ( 'disconnect' , bind ( this , '_ondisconnect' ) ) ; this . encoder . on ( 'stream' , bind ( this , '_onencode' ) ) ; this . decoder . on ( 'stream' , bind ( this , '_ondecode' ) ) ; }
Bidirectional stream socket which wraps Socket.IO.

@param {socket.io#Socket} socket.io
@api public
Bidirectional stream socket which wraps Socket . IO .