lib/connection.js
function Connection(socket) {
  events.EventEmitter.call(this);

  // underlying socket
  this._socket = socket;

  // flag whether this connection is paused
  this._paused = false;

  // external or in-process client connection
  this._tcp = (this._socket instanceof Socket);

  // state information
  this._client = new Client(socket);

  this.data = this.data.bind(this);

  this._socket.once('close', this._close.bind(this));
  this._socket.on('data', this.data);

  // using a tcp socket connection
  if(this._tcp) {
    this.encoder = new Encoder({return_buffers: true})
    this.encoder.on('push', onPush.bind(this));
    this.encoder.pipe(this._socket);
    this.decoder = new Decoder({return_buffers: true});
    this.decoder.on('reply', this.decoded.bind(this));
    this.decoder.on('error', this.decoded.bind(this));

    function onSocketError(err) {
      log.warning(err.message);
    }

    this._socket.on('error', onSocketError.bind(this));
  }

  this.onWrite = this.onWrite.bind(this);
}
function Connection(socket) {
  events.EventEmitter.call(this);

  // underlying socket
  this._socket = socket;

  // flag whether this connection is paused
  this._paused = false;

  // external or in-process client connection
  this._tcp = (this._socket instanceof Socket);

  // state information
  this._client = new Client(socket);

  this.data = this.data.bind(this);

  this._socket.once('close', this._close.bind(this));
  this._socket.on('data', this.data);

  // using a tcp socket connection
  if(this._tcp) {
    this.encoder = new Encoder({return_buffers: true})
    this.encoder.on('push', onPush.bind(this));
    this.encoder.pipe(this._socket);
    this.decoder = new Decoder({return_buffers: true});
    this.decoder.on('reply', this.decoded.bind(this));
    this.decoder.on('error', this.decoded.bind(this));

    function onSocketError(err) {
      log.warning(err.message);
    }

    this._socket.on('error', onSocketError.bind(this));
  }

  this.onWrite = this.onWrite.bind(this);
}
function Connection ( socket ) { events . EventEmitter . call ( this ) ; // underlying socket this . _socket = socket ; // flag whether this connection is paused this . _paused = false ; // external or in-process client connection this . _tcp = ( this . _socket instanceof Socket ) ; // state information this . _client = new Client ( socket ) ; this . data = this . data . bind ( this ) ; this . _socket . once ( 'close' , this . _close . bind ( this ) ) ; this . _socket . on ( 'data' , this . data ) ; // using a tcp socket connection if ( this . _tcp ) { this . encoder = new Encoder ( { return_buffers : true } ) this . encoder . on ( 'push' , onPush . bind ( this ) ) ; this . encoder . pipe ( this . _socket ) ; this . decoder = new Decoder ( { return_buffers : true } ) ; this . decoder . on ( 'reply' , this . decoded . bind ( this ) ) ; this . decoder . on ( 'error' , this . decoded . bind ( this ) ) ; function onSocketError ( err ) { log . warning ( err . message ) ; } this . _socket . on ( 'error' , onSocketError . bind ( this ) ) ; } this . onWrite = this . onWrite . bind ( this ) ; }
Encapsulates a client socket connection.
Encapsulates a client socket connection .