public abstract static class ServerCall.Listener<ReqT> extends Object
Any contexts are guaranteed to arrive before any messages, which are guaranteed before half close, which is guaranteed before completion.
Implementations are free to block for extended periods of time. Implementations are not required to be thread-safe, but they must not be thread-hostile. The caller is free to call an instance from multiple threads, but only one call simultaneously. A single thread may interleave calls to multiple instances, so implementations using ThreadLocals must be careful to avoid leaking inappropriate state (e.g., clearing the ThreadLocal before returning).
Constructor and Description |
---|
Listener() |
Modifier and Type | Method and Description |
---|---|
void |
onCancel()
The call was cancelled and the server is encouraged to abort processing to save resources,
since the client will not process any further messages.
|
void |
onComplete()
The call is considered complete and
onCancel() is guaranteed not to be called. |
void |
onHalfClose()
The client completed all message sending.
|
void |
onMessage(ReqT message)
A request message has been received.
|
void |
onReady()
This indicates that the call may now be capable of sending additional messages (via
ServerCall.sendMessage(RespT) ) without requiring excessive buffering internally. |
public void onMessage(ReqT message)
message
- a received request message.public void onHalfClose()
public void onCancel()
There will be no further callbacks for the call.
public void onComplete()
onCancel()
is guaranteed not to be called.
However, the client is not guaranteed to have received all messages.
There will be no further callbacks for the call.
public void onReady()
ServerCall.sendMessage(RespT)
) without requiring excessive buffering internally. This event is
just a suggestion and the application is free to ignore it, however doing so may
result in excessive buffering within the call.
Because there is a processing delay to deliver this notification, it is possible for
concurrent writes to cause isReady() == false
within this callback. Handle "spurious"
notifications by checking isReady()
's current value instead of assuming it is now
true
. If isReady() == false
the normal expectations apply, so there would be
another onReady()
callback.