lib/rpc-client/client.js
function(client, serverType, msg, routeParam, cb) {
  if (!!client.routerType) {
    let method;
    switch (client.routerType) {
      case constants.SCHEDULE.ROUNDROBIN:
        method = router.rr;
        break;
      case constants.SCHEDULE.WEIGHT_ROUNDROBIN:
        method = router.wrr;
        break;
      case constants.SCHEDULE.LEAST_ACTIVE:
        method = router.la;
        break;
      case constants.SCHEDULE.CONSISTENT_HASH:
        method = router.ch;
        break;
      default:
        method = router.rd;
        break;
    }
    method.call(null, client, serverType, msg, function(err, serverId) {
      cb(err, serverId);
    });
  } else {
    let route, target;
    if (typeof client.router === 'function') {
      route = client.router;
      target = null;
    } else if (typeof client.router.route === 'function') {
      route = client.router.route;
      target = client.router;
    } else {
      logger.error('[omelo-rpc] invalid route function.');
      return;
    }
    route.call(target, routeParam, msg, client._routeContext, function(err, serverId) {
      cb(err, serverId);
    });
  }
}
function(client, serverType, msg, routeParam, cb) {
  if (!!client.routerType) {
    let method;
    switch (client.routerType) {
      case constants.SCHEDULE.ROUNDROBIN:
        method = router.rr;
        break;
      case constants.SCHEDULE.WEIGHT_ROUNDROBIN:
        method = router.wrr;
        break;
      case constants.SCHEDULE.LEAST_ACTIVE:
        method = router.la;
        break;
      case constants.SCHEDULE.CONSISTENT_HASH:
        method = router.ch;
        break;
      default:
        method = router.rd;
        break;
    }
    method.call(null, client, serverType, msg, function(err, serverId) {
      cb(err, serverId);
    });
  } else {
    let route, target;
    if (typeof client.router === 'function') {
      route = client.router;
      target = null;
    } else if (typeof client.router.route === 'function') {
      route = client.router.route;
      target = client.router;
    } else {
      logger.error('[omelo-rpc] invalid route function.');
      return;
    }
    route.call(target, routeParam, msg, client._routeContext, function(err, serverId) {
      cb(err, serverId);
    });
  }
}
function ( client , serverType , msg , routeParam , cb ) { if ( ! ! client . routerType ) { let method ; switch ( client . routerType ) { case constants . SCHEDULE . ROUNDROBIN : method = router . rr ; break ; case constants . SCHEDULE . WEIGHT_ROUNDROBIN : method = router . wrr ; break ; case constants . SCHEDULE . LEAST_ACTIVE : method = router . la ; break ; case constants . SCHEDULE . CONSISTENT_HASH : method = router . ch ; break ; default : method = router . rd ; break ; } method . call ( null , client , serverType , msg , function ( err , serverId ) { cb ( err , serverId ) ; } ) ; } else { let route , target ; if ( typeof client . router === 'function' ) { route = client . router ; target = null ; } else if ( typeof client . router . route === 'function' ) { route = client . router . route ; target = client . router ; } else { logger . error ( '[omelo-rpc] invalid route function.' ) ; return ; } route . call ( target , routeParam , msg , client . _routeContext , function ( err , serverId ) { cb ( err , serverId ) ; } ) ; } }
Calculate remote target server id for rpc client.

@param client {Object} current client instance.
@param serverType {String} remote server type.
@param routeParam {Object} mailbox init context parameter.
@param cb {Function} return rpc remote target server id.

@api private
Calculate remote target server id for rpc client .