lib/jsonrpc-tcp/remote.js
function Remote(connection) {
  this.timeout = 5000;
  this._connection = connection;
  this._handlers = {};
  this._requestID = 1;
  
  var self = this;
  this._connection.addListener('response', function(res) {
    if (res.id === null || res.id === undefined) { return; }
    var handler = self._handlers[res.id];
    if (handler) { handler.call(self, res.error, res.result); }
    delete self._handlers[res.id];
  });
}
function Remote(connection) {
  this.timeout = 5000;
  this._connection = connection;
  this._handlers = {};
  this._requestID = 1;
  
  var self = this;
  this._connection.addListener('response', function(res) {
    if (res.id === null || res.id === undefined) { return; }
    var handler = self._handlers[res.id];
    if (handler) { handler.call(self, res.error, res.result); }
    delete self._handlers[res.id];
  });
}
function Remote ( connection ) { this . timeout = 5000 ; this . _connection = connection ; this . _handlers = { } ; this . _requestID = 1 ; var self = this ; this . _connection . addListener ( 'response' , function ( res ) { if ( res . id === null || res . id === undefined ) { return ; } var handler = self . _handlers [ res . id ] ; if ( handler ) { handler . call ( self , res . error , res . result ) ; } delete self . _handlers [ res . id ] ; } ) ; }
Create a new remote JSON-RPC peer over `connection`.

`Remote` provides a convienient abstraction over a JSON-RPC connection,
allowing methods to be invoked and responses to be received asynchronously.

A `Remote` instance will automatically be created for each connection.  There
is no need to do so manually.

@api private
Create a new remote JSON - RPC peer over connection .