jrpc.js
function serveRequest(request) {
  var id = null;
  var params = null;

  if (!this.active || typeof request !== 'object' || request === null) {
    return;
  }

  if (!(typeof request.jsonrpc === 'string' && request.jsonrpc === '2.0')) {
    return;
  }

  id = (typeof request.id !== 'undefined' ? request.id : null);
  if (typeof request.method !== 'string') {
    if (id !== null) {
      this.localTimers[id] = true;
      setImmediate(sendResponse.bind(this, id, -32600));
    }
    return;
  }

  if (!(request.method in this.exposed)) {
    if (id !== null) {
      this.localTimers[id] = true;
      setImmediate(sendResponse.bind(this, id, -32601));
    }
    return;
  }

  if ('params' in request) {
    if (typeof request['params'] === 'object') {
      params = request['params'];
    } else {
      if (id !== null) {
        this.localTimers[id] = true;
        setImmediate(sendResponse.bind(this, id, -32602));
      }
      return;
    }
  }

  if (id !== null) {
    if (this.localTimeout > 0) {
      this.localTimers[id] = setTimeout(
        sendResponse.bind(
          this,
          id,
          {
            code   : -1002,
            message: 'Method handler timed out'
          }
        ),
        this.localTimeout
      );
    } else {
      this.localTimers[id] = true;
    }
  }
  setImmediate(
    this.exposed[request.method],
    params,
    sendResponse.bind(this, id)
  );

  return;
}
function serveRequest(request) {
  var id = null;
  var params = null;

  if (!this.active || typeof request !== 'object' || request === null) {
    return;
  }

  if (!(typeof request.jsonrpc === 'string' && request.jsonrpc === '2.0')) {
    return;
  }

  id = (typeof request.id !== 'undefined' ? request.id : null);
  if (typeof request.method !== 'string') {
    if (id !== null) {
      this.localTimers[id] = true;
      setImmediate(sendResponse.bind(this, id, -32600));
    }
    return;
  }

  if (!(request.method in this.exposed)) {
    if (id !== null) {
      this.localTimers[id] = true;
      setImmediate(sendResponse.bind(this, id, -32601));
    }
    return;
  }

  if ('params' in request) {
    if (typeof request['params'] === 'object') {
      params = request['params'];
    } else {
      if (id !== null) {
        this.localTimers[id] = true;
        setImmediate(sendResponse.bind(this, id, -32602));
      }
      return;
    }
  }

  if (id !== null) {
    if (this.localTimeout > 0) {
      this.localTimers[id] = setTimeout(
        sendResponse.bind(
          this,
          id,
          {
            code   : -1002,
            message: 'Method handler timed out'
          }
        ),
        this.localTimeout
      );
    } else {
      this.localTimers[id] = true;
    }
  }
  setImmediate(
    this.exposed[request.method],
    params,
    sendResponse.bind(this, id)
  );

  return;
}
function serveRequest ( request ) { var id = null ; var params = null ; if ( ! this . active || typeof request !== 'object' || request === null ) { return ; } if ( ! ( typeof request . jsonrpc === 'string' && request . jsonrpc === '2.0' ) ) { return ; } id = ( typeof request . id !== 'undefined' ? request . id : null ) ; if ( typeof request . method !== 'string' ) { if ( id !== null ) { this . localTimers [ id ] = true ; setImmediate ( sendResponse . bind ( this , id , - 32600 ) ) ; } return ; } if ( ! ( request . method in this . exposed ) ) { if ( id !== null ) { this . localTimers [ id ] = true ; setImmediate ( sendResponse . bind ( this , id , - 32601 ) ) ; } return ; } if ( 'params' in request ) { if ( typeof request [ 'params' ] === 'object' ) { params = request [ 'params' ] ; } else { if ( id !== null ) { this . localTimers [ id ] = true ; setImmediate ( sendResponse . bind ( this , id , - 32602 ) ) ; } return ; } } if ( id !== null ) { if ( this . localTimeout > 0 ) { this . localTimers [ id ] = setTimeout ( sendResponse . bind ( this , id , { code : - 1002 , message : 'Method handler timed out' } ) , this . localTimeout ) ; } else { this . localTimers [ id ] = true ; } } setImmediate ( this . exposed [ request . method ] , params , sendResponse . bind ( this , id ) ) ; return ; }
Callback invoked to handle calls to our side's methods

@callback JRPC~serviceCallback

@param {(Object|Array|null)}        params Parameters received
@param {JRPC~serviceResultCallback} next   Callback to send your result

@return {undefined} No return value
 
Serve a request we received

@param {Object} request Request to parse

@return {undefined} No return value
Callback invoked to handle calls to our side s methods