lib/services.js
function ClientChannel(client, opts) {
  opts = opts || {};
  events.EventEmitter.call(this);

  this.client = client;
  this.timeout = utils.getOption(opts, 'timeout', client._timeout$);
  this._endWritable = !!utils.getOption(opts, 'endWritable', true);
  this._prefix = normalizedPrefix(opts.scope);

  var cache = client._cache$;
  var clientSvc = client._svc$;
  var hash = opts.serverHash;
  if (!hash) {
    hash = clientSvc.hash;
  }
  var adapter = cache[hash];
  if (!adapter) {
    // This might happen even if the server hash option was set if the cache
    // doesn't contain the corresponding adapter. In this case we fall back to
    // the client's protocol (as mandated by the spec).
    hash = clientSvc.hash;
    adapter = cache[hash] = new Adapter(clientSvc, clientSvc, hash);
  }
  this._adapter = adapter;

  this._registry = new Registry(this, PREFIX_LENGTH);
  this.pending = 0;
  this.destroyed = false;
  this.draining = false;
  this.once('_eot', function (pending, err) {
    // Since this listener is only run once, we will only forward an error if
    // it is present during the initial `destroy` call, which is OK.
    debug('client channel EOT');
    this.destroyed = true;
    this.emit('eot', pending, err);
  });
}
function ClientChannel(client, opts) {
  opts = opts || {};
  events.EventEmitter.call(this);

  this.client = client;
  this.timeout = utils.getOption(opts, 'timeout', client._timeout$);
  this._endWritable = !!utils.getOption(opts, 'endWritable', true);
  this._prefix = normalizedPrefix(opts.scope);

  var cache = client._cache$;
  var clientSvc = client._svc$;
  var hash = opts.serverHash;
  if (!hash) {
    hash = clientSvc.hash;
  }
  var adapter = cache[hash];
  if (!adapter) {
    // This might happen even if the server hash option was set if the cache
    // doesn't contain the corresponding adapter. In this case we fall back to
    // the client's protocol (as mandated by the spec).
    hash = clientSvc.hash;
    adapter = cache[hash] = new Adapter(clientSvc, clientSvc, hash);
  }
  this._adapter = adapter;

  this._registry = new Registry(this, PREFIX_LENGTH);
  this.pending = 0;
  this.destroyed = false;
  this.draining = false;
  this.once('_eot', function (pending, err) {
    // Since this listener is only run once, we will only forward an error if
    // it is present during the initial `destroy` call, which is OK.
    debug('client channel EOT');
    this.destroyed = true;
    this.emit('eot', pending, err);
  });
}
function ClientChannel ( client , opts ) { opts = opts || { } ; events . EventEmitter . call ( this ) ; this . client = client ; this . timeout = utils . getOption ( opts , 'timeout' , client . _timeout$ ) ; this . _endWritable = ! ! utils . getOption ( opts , 'endWritable' , true ) ; this . _prefix = normalizedPrefix ( opts . scope ) ; var cache = client . _cache$ ; var clientSvc = client . _svc$ ; var hash = opts . serverHash ; if ( ! hash ) { hash = clientSvc . hash ; } var adapter = cache [ hash ] ; if ( ! adapter ) { // This might happen even if the server hash option was set if the cache // doesn't contain the corresponding adapter. In this case we fall back to // the client's protocol (as mandated by the spec). hash = clientSvc . hash ; adapter = cache [ hash ] = new Adapter ( clientSvc , clientSvc , hash ) ; } this . _adapter = adapter ; this . _registry = new Registry ( this , PREFIX_LENGTH ) ; this . pending = 0 ; this . destroyed = false ; this . draining = false ; this . once ( '_eot' , function ( pending , err ) { // Since this listener is only run once, we will only forward an error if // it is present during the initial `destroy` call, which is OK. debug ( 'client channel EOT' ) ; this . destroyed = true ; this . emit ( 'eot' , pending , err ) ; } ) ; }
Base message emitter class. See below for the two available variants.
Base message emitter class . See below for the two available variants .