lib/wsmux.js
function WSMuxChannel(id, mux) {
  EventEmitter.call(this);
  this.id = id;
  this.mux = mux;
  this.closed = false;
  this.url = this.mux.url;

  // websocket-stream relies on this method
  this.__defineGetter__('readyState', function() {
    return this.mux._readyState();
  });

  // hooks for websocket-stream
  var _this = this;
  this.on('open', function() {
    _this.onopen && _this.onopen.apply(_this, arguments);
  });

  this.on('close', function() {
    _this.onclose && _this.onclose.apply(_this, arguments);
  });

  this.on('error', function() {
    _this.onerror && _this.onerror.apply(_this, arguments);
  });

  this.on('message', function() {
    arguments[0] = {data: arguments[0]}
    _this.onmessage && _this.onmessage.apply(_this, arguments);
  });
}
function WSMuxChannel(id, mux) {
  EventEmitter.call(this);
  this.id = id;
  this.mux = mux;
  this.closed = false;
  this.url = this.mux.url;

  // websocket-stream relies on this method
  this.__defineGetter__('readyState', function() {
    return this.mux._readyState();
  });

  // hooks for websocket-stream
  var _this = this;
  this.on('open', function() {
    _this.onopen && _this.onopen.apply(_this, arguments);
  });

  this.on('close', function() {
    _this.onclose && _this.onclose.apply(_this, arguments);
  });

  this.on('error', function() {
    _this.onerror && _this.onerror.apply(_this, arguments);
  });

  this.on('message', function() {
    arguments[0] = {data: arguments[0]}
    _this.onmessage && _this.onmessage.apply(_this, arguments);
  });
}
function WSMuxChannel ( id , mux ) { EventEmitter . call ( this ) ; this . id = id ; this . mux = mux ; this . closed = false ; this . url = this . mux . url ; // websocket-stream relies on this method this . __defineGetter__ ( 'readyState' , function ( ) { return this . mux . _readyState ( ) ; } ) ; // hooks for websocket-stream var _this = this ; this . on ( 'open' , function ( ) { _this . onopen && _this . onopen . apply ( _this , arguments ) ; } ) ; this . on ( 'close' , function ( ) { _this . onclose && _this . onclose . apply ( _this , arguments ) ; } ) ; this . on ( 'error' , function ( ) { _this . onerror && _this . onerror . apply ( _this , arguments ) ; } ) ; this . on ( 'message' , function ( ) { arguments [ 0 ] = { data : arguments [ 0 ] } _this . onmessage && _this . onmessage . apply ( _this , arguments ) ; } ) ; }
A channel on a mulitplexed websocket
@param id the id of the channel
@param mux the parent websocket multiplexer
@constructor
A channel on a mulitplexed websocket