lib/services.js
function discoverProtocol(transport, opts, cb) {
  if (cb === undefined && typeof opts == 'function') {
    cb = opts;
    opts = undefined;
  }

  var svc = new Service({protocol: 'Empty'}, OPTS);
  var ptclStr;
  svc.createClient({timeout: opts && opts.timeout})
    .createChannel(transport, {
      scope: opts && opts.scope,
      endWritable: typeof transport == 'function' // Stateless transports only.
    }).once('handshake', function (hreq, hres) {
        ptclStr = hres.serverProtocol;
        this.destroy(true);
      })
      .once('eot', function (pending, err) {
        // Stateless transports will throw an interrupted error when the
        // channel is destroyed, we ignore it here.
        if (err && !/interrupted/.test(err)) {
          cb(err); // Likely timeout.
        } else {
          cb(null, JSON.parse(ptclStr));
        }
      });
}
function discoverProtocol(transport, opts, cb) {
  if (cb === undefined && typeof opts == 'function') {
    cb = opts;
    opts = undefined;
  }

  var svc = new Service({protocol: 'Empty'}, OPTS);
  var ptclStr;
  svc.createClient({timeout: opts && opts.timeout})
    .createChannel(transport, {
      scope: opts && opts.scope,
      endWritable: typeof transport == 'function' // Stateless transports only.
    }).once('handshake', function (hreq, hres) {
        ptclStr = hres.serverProtocol;
        this.destroy(true);
      })
      .once('eot', function (pending, err) {
        // Stateless transports will throw an interrupted error when the
        // channel is destroyed, we ignore it here.
        if (err && !/interrupted/.test(err)) {
          cb(err); // Likely timeout.
        } else {
          cb(null, JSON.parse(ptclStr));
        }
      });
}
function discoverProtocol ( transport , opts , cb ) { if ( cb === undefined && typeof opts == 'function' ) { cb = opts ; opts = undefined ; } var svc = new Service ( { protocol : 'Empty' } , OPTS ) ; var ptclStr ; svc . createClient ( { timeout : opts && opts . timeout } ) . createChannel ( transport , { scope : opts && opts . scope , endWritable : typeof transport == 'function' // Stateless transports only. } ) . once ( 'handshake' , function ( hreq , hres ) { ptclStr = hres . serverProtocol ; this . destroy ( true ) ; } ) . once ( 'eot' , function ( pending , err ) { // Stateless transports will throw an interrupted error when the // channel is destroyed, we ignore it here. if ( err && ! / interrupted / . test ( err ) ) { cb ( err ) ; // Likely timeout. } else { cb ( null , JSON . parse ( ptclStr ) ) ; } } ) ; }
Function to retrieve a remote service's protocol.
Function to retrieve a remote service s protocol .