packages/grpc-native-core/src/server.js
function handleUnary(call, handler, metadata) {
  var emitter = new ServerUnaryCall(call, metadata);
  emitter.on('error', function(error) {
    handleError(call, error);
  });
  emitter.waitForCancel();
  var batch = {};
  batch[grpc.opType.RECV_MESSAGE] = true;
  call.startBatch(batch, function(err, result) {
    if (err) {
      handleError(call, err);
      return;
    }
    try {
      emitter.request = handler.deserialize(result.read);
    } catch (e) {
      e.code = constants.status.INTERNAL;
      handleError(call, e);
      return;
    }
    if (emitter.cancelled) {
      return;
    }
    handler.func(emitter, function sendUnaryData(err, value, trailer, flags) {
      if (err) {
        if (trailer) {
          err.metadata = trailer;
        }
        handleError(call, err);
      } else {
        sendUnaryResponse(call, value, handler.serialize, trailer, flags);
      }
    });
  });
}
function handleUnary(call, handler, metadata) {
  var emitter = new ServerUnaryCall(call, metadata);
  emitter.on('error', function(error) {
    handleError(call, error);
  });
  emitter.waitForCancel();
  var batch = {};
  batch[grpc.opType.RECV_MESSAGE] = true;
  call.startBatch(batch, function(err, result) {
    if (err) {
      handleError(call, err);
      return;
    }
    try {
      emitter.request = handler.deserialize(result.read);
    } catch (e) {
      e.code = constants.status.INTERNAL;
      handleError(call, e);
      return;
    }
    if (emitter.cancelled) {
      return;
    }
    handler.func(emitter, function sendUnaryData(err, value, trailer, flags) {
      if (err) {
        if (trailer) {
          err.metadata = trailer;
        }
        handleError(call, err);
      } else {
        sendUnaryResponse(call, value, handler.serialize, trailer, flags);
      }
    });
  });
}
function handleUnary ( call , handler , metadata ) { var emitter = new ServerUnaryCall ( call , metadata ) ; emitter . on ( 'error' , function ( error ) { handleError ( call , error ) ; } ) ; emitter . waitForCancel ( ) ; var batch = { } ; batch [ grpc . opType . RECV_MESSAGE ] = true ; call . startBatch ( batch , function ( err , result ) { if ( err ) { handleError ( call , err ) ; return ; } try { emitter . request = handler . deserialize ( result . read ) ; } catch ( e ) { e . code = constants . status . INTERNAL ; handleError ( call , e ) ; return ; } if ( emitter . cancelled ) { return ; } handler . func ( emitter , function sendUnaryData ( err , value , trailer , flags ) { if ( err ) { if ( trailer ) { err . metadata = trailer ; } handleError ( call , err ) ; } else { sendUnaryResponse ( call , value , handler . serialize , trailer , flags ) ; } } ) ; } ) ; }
User-provided method to handle unary requests on a server
@callback grpc.Server~handleUnaryCall
@param {grpc~ServerUnaryCall} call The call object
@param {grpc.Server~sendUnaryData} callback The callback to call to respond
to the request
 
Fully handle a unary call
@private
@param {grpc.internal~Call} call The call to handle
@param {Object} handler Request handler object for the method that was called
@param {grpc~Server.handleUnaryCall} handler.func The handler function
@param {grpc~deserialize} handler.deserialize The deserialization function
for request data
@param {grpc~serialize} handler.serialize The serialization function for
response data
@param {grpc.Metadata} metadata Metadata from the client
User - provided method to handle unary requests on a server