Java Code Examples for io.grpc.ServerCall#sendMessage()

The following examples show how to use io.grpc.ServerCall#sendMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoadServer.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Override
public ServerCall.Listener<ByteBuf> startCall(
    final ServerCall<ByteBuf, ByteBuf> call, Metadata headers) {
  call.sendHeaders(new Metadata());
  call.request(1);
  return new ServerCall.Listener<ByteBuf>() {
    @Override
    public void onMessage(ByteBuf message) {
      // no-op
      message.release();
      call.request(1);
      call.sendMessage(genericResponse.slice());
    }

    @Override
    public void onHalfClose() {
      call.close(Status.OK, new Metadata());
    }

    @Override
    public void onCancel() {
    }

    @Override
    public void onComplete() {
    }
  };
}
 
Example 2
Source File: LoadServer.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Override
public ServerCall.Listener<ByteBuf> startCall(
    final ServerCall<ByteBuf, ByteBuf> call, Metadata headers) {
  call.sendHeaders(new Metadata());
  call.request(1);
  return new ServerCall.Listener<ByteBuf>() {
    @Override
    public void onMessage(ByteBuf message) {
      // no-op
      message.release();
      call.request(1);
      call.sendMessage(genericResponse.slice());
    }

    @Override
    public void onHalfClose() {
      call.close(Status.OK, new Metadata());
    }

    @Override
    public void onCancel() {
    }

    @Override
    public void onComplete() {
    }
  };
}