In the past, I created a final AtomicReference and assigned the
requestObserver to it and then called a get on the atomic reference in the
onNext of the response onserver when I wanted to ping pong back and forth.
It works, but also felt a bit off, so if anyone has better I’d love to hear
it!

William Thurston

On Dec 6, 2017, at 8:09 PM, "luis.e.sanc...@gmail.com" <
luis.e.sanc...@gmail.com> wrote:

I have a bi-directional RPC, let's use the sample StreamingGreeter
<https://github.com/grpc/grpc-java/blob/master/examples/src/main/proto/hello_streaming.proto>
.

I need to register a response observer:

// a response observer
StreamObserver<HelloReply> responseObserver = new StreamObserver<HelloReply
>() { ... };


StreamingGreeterGrpc.StreamingGreeterStub stub = StreamingGreeterGrpc.
newStub(channel);



// calling the streaming rpc returns the request observer
StreamObserver<HelloRequest> requestObserver = stub.SayHelloStreaming(
responseObserver);



So, how do I safely use the request observer from within the response
observer, given that the response observer has to be created before the rpc
call and the request observer is only available after the rpc call?

In my example, upon receiving HelloReply, I might want to, for example
trigger sending another HelloRequest (for whatever reason).



-- 
You received this message because you are subscribed to the Google Groups "
grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to grpc-io+unsubscr...@googlegroups.com.
To post to this group, send email to grpc-io@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/2a232c67-14d9-4700-9b35-47cababb7c22%40googlegroups.com
<https://groups.google.com/d/msgid/grpc-io/2a232c67-14d9-4700-9b35-47cababb7c22%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To post to this group, send email to grpc-io@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/-7349160829354649211%40unknownmsgid.
For more options, visit https://groups.google.com/d/optout.

Reply via email to