packages/grpc-native-core/src/server.js
function _write(chunk, encoding, callback) {
  /* jshint validthis: true */
  var batch = {};
  var self = this;
  var message;
  try {
    message = this.serialize(chunk);
  } catch (e) {
    e.code = constants.status.INTERNAL;
    callback(e);
    return;
  }
  if (!this.call.metadataSent) {
    batch[grpc.opType.SEND_INITIAL_METADATA] =
        (new Metadata())._getCoreRepresentation();
    this.call.metadataSent = true;
  }
  if (Number.isFinite(encoding)) {
    /* Attach the encoding if it is a finite number. This is the closest we
     * can get to checking that it is valid flags */
    message.grpcWriteFlags = encoding;
  }
  batch[grpc.opType.SEND_MESSAGE] = message;
  this.call.startBatch(batch, function(err, value) {
    if (err) {
      self.emit('error', err);
      return;
    }
    callback();
  });
}
function _write(chunk, encoding, callback) {
  /* jshint validthis: true */
  var batch = {};
  var self = this;
  var message;
  try {
    message = this.serialize(chunk);
  } catch (e) {
    e.code = constants.status.INTERNAL;
    callback(e);
    return;
  }
  if (!this.call.metadataSent) {
    batch[grpc.opType.SEND_INITIAL_METADATA] =
        (new Metadata())._getCoreRepresentation();
    this.call.metadataSent = true;
  }
  if (Number.isFinite(encoding)) {
    /* Attach the encoding if it is a finite number. This is the closest we
     * can get to checking that it is valid flags */
    message.grpcWriteFlags = encoding;
  }
  batch[grpc.opType.SEND_MESSAGE] = message;
  this.call.startBatch(batch, function(err, value) {
    if (err) {
      self.emit('error', err);
      return;
    }
    callback();
  });
}
function _write ( chunk , encoding , callback ) { /* jshint validthis: true */ var batch = { } ; var self = this ; var message ; try { message = this . serialize ( chunk ) ; } catch ( e ) { e . code = constants . status . INTERNAL ; callback ( e ) ; return ; } if ( ! this . call . metadataSent ) { batch [ grpc . opType . SEND_INITIAL_METADATA ] = ( new Metadata ( ) ) . _getCoreRepresentation ( ) ; this . call . metadataSent = true ; } if ( Number . isFinite ( encoding ) ) { /* Attach the encoding if it is a finite number. This is the closest we
     * can get to checking that it is valid flags */ message . grpcWriteFlags = encoding ; } batch [ grpc . opType . SEND_MESSAGE ] = message ; this . call . startBatch ( batch , function ( err , value ) { if ( err ) { self . emit ( 'error' , err ) ; return ; } callback ( ) ; } ) ; }
Start writing a chunk of data. This is an implementation of a method required
for implementing stream.Writable.
@private
@param {Buffer} chunk The chunk of data to write
@param {string} encoding Used to pass write flags
@param {function(Error=)} callback Callback to indicate that the write is
complete
Start writing a chunk of data . This is an implementation of a method required for implementing stream . Writable .