Java 类io.grpc.stub.ServerCalls.UnaryMethod 实例源码

项目:book_ldrtc    文件:HelloJsonServer.java   
private ServerServiceDefinition bindService(final Greeter serviceImpl) {
  return io.grpc.ServerServiceDefinition.builder(GreeterGrpc.SERVICE_NAME)
      .addMethod(
        HelloJsonClient.HelloJsonStub.METHOD_SAY_HELLO,
        asyncUnaryCall(
            new UnaryMethod<HelloRequest, HelloReply>() {
              @Override
              public void invoke(
                  HelloRequest request, StreamObserver<HelloReply> responseObserver) {
                serviceImpl.sayHello(request, responseObserver);
              }
            }))
      .build();
}
项目:grpc-java    文件:HelloJsonServer.java   
@Override
public ServerServiceDefinition bindService() {
  return io.grpc.ServerServiceDefinition
      .builder(GreeterGrpc.getServiceDescriptor().getName())
      .addMethod(HelloJsonClient.HelloJsonStub.METHOD_SAY_HELLO,
          asyncUnaryCall(
              new UnaryMethod<HelloRequest, HelloReply>() {
                @Override
                public void invoke(
                    HelloRequest request, StreamObserver<HelloReply> responseObserver) {
                  sayHello(request, responseObserver);
                }
              }))
      .build();
}