Skip to content

Instantly share code, notes, and snippets.

@KKcorps
Created September 9, 2019 16:54
Show Gist options
  • Save KKcorps/5911427b892d831f8f0981f3dcfac932 to your computer and use it in GitHub Desktop.
Save KKcorps/5911427b892d831f8f0981f3dcfac932 to your computer and use it in GitHub Desktop.
GreeterImpl.java
private class GreeterImpl extends GreeterGrpc.GreeterImplBase {
@Override
public void sayHello(HelloRequest req, StreamObserver<HelloReply> responseObserver) {
//Build Proto Messages Object
HelloReply reply = HelloReply.newBuilder().setMessage("Hello " + req.getName()).build();
//Send the response, you can send multiple objects which will be trasmitted in streaming fashion
responseObserver.onNext(reply);
//Indicate client that response has finished
responseObserver.onCompleted();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment