public abstract static class ForwardingClientCallListener.SimpleForwardingClientCallListener<RespT> extends ForwardingClientCallListener<RespT>
ForwardingClientCallListener
where subclasses can pass in a
ClientCall.Listener
as the delegate.ForwardingClientCallListener.SimpleForwardingClientCallListener<RespT>
Modifier | Constructor and Description |
---|---|
protected |
SimpleForwardingClientCallListener(ClientCall.Listener<RespT> delegate) |
Modifier and Type | Method and Description |
---|---|
protected ClientCall.Listener<RespT> |
delegate()
Returns the delegated
ClientCall.Listener . |
void |
onClose(Status status,
Metadata trailers)
The ClientCall has been closed.
|
void |
onHeaders(Metadata headers)
The response headers have been received.
|
void |
onReady()
This indicates that the ClientCall may now be capable of sending additional messages (via
ClientCall.sendMessage(ReqT) ) without requiring excessive buffering internally. |
java.lang.String |
toString() |
onMessage
protected SimpleForwardingClientCallListener(ClientCall.Listener<RespT> delegate)
protected ClientCall.Listener<RespT> delegate()
ForwardingClientCallListener
ClientCall.Listener
.delegate
in class ForwardingClientCallListener<RespT>
public void onHeaders(Metadata headers)
ClientCall.Listener
Since Metadata
is not thread-safe, the caller must not access (read or write)
headers
after this point.
onHeaders
in class ClientCall.Listener<RespT>
headers
- containing metadata sent by the server at the start of the response.public void onClose(Status status, Metadata trailers)
ClientCall.Listener
ClientCall
will not be
processed by the server. No further receiving will occur and no further notifications will be
made.
Since Metadata
is not thread-safe, the caller must not access (read or write)
trailers
after this point.
If status
returns false for Status.isOk()
, then the call failed.
An additional block of trailer metadata may be received at the end of the call from the
server. An empty Metadata
object is passed if no trailers are received.
This method should not throw. If this method throws, there is no way to be notified of the exception. Implementations should therefore be careful of exceptions which can accidentally leak resources.
onClose
in class ClientCall.Listener<RespT>
status
- the result of the remote call.trailers
- metadata provided at call completion.public void onReady()
ClientCall.Listener
ClientCall.sendMessage(ReqT)
) 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 ClientCall.
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.
If the type of a call is either MethodDescriptor.MethodType.UNARY
or
MethodDescriptor.MethodType.SERVER_STREAMING
, this callback may not be fired. Calls
that send exactly one message should not await this callback.
onReady
in class ClientCall.Listener<RespT>
public java.lang.String toString()
toString
in class java.lang.Object