WARNING! I do not know if this is the correct way to implement server push.
-
Construct a stream-stream connection.
-
In client-side, pass the id of client via metadata. The stub should return an iterator, and call
next()method of this method will block cause server has not responsed yet. -
In server-side, when it receives the first request, construct a new
Queue. Then, blocking reading this queue byQueue.get(). Once some new data is written into this queue, server will raise a response to client. In this example, writter is a standardinputwhich is invoked in another thread.
