@BetaApi(value="The surface for streaming is not stable yet and may change in the future.") public abstract class StateCheckingResponseObserver<V> extends Object implements ResponseObserver<V>
ResponseObserver that performs state sanity checks.| Constructor and Description |
|---|
StateCheckingResponseObserver() |
| Modifier and Type | Method and Description |
|---|---|
void |
onComplete()
Receives a notification of successful stream completion.
|
protected abstract void |
onCompleteImpl() |
void |
onError(Throwable t)
Receives a terminating error from the stream.
|
protected abstract void |
onErrorImpl(Throwable t) |
void |
onResponse(V response)
Receives a value from the stream.
|
protected abstract void |
onResponseImpl(V response) |
void |
onStart(StreamController controller)
Called before the stream is started.
|
protected abstract void |
onStartImpl(StreamController controller) |
public final void onStart(StreamController controller)
ServerStreamingCallable.call(Object, ResponseObserver, ApiCallContext)
Allows for disabling flow control and early stream termination via StreamController.
This implementation simply delegates to onStartImpl(StreamController) after
ensuring consistent state.
onStart in interface ResponseObserver<V>controller - The controller for the stream.public final void onResponse(V response)
Can be called many times but is never called after ResponseObserver.onError(Throwable) or ResponseObserver.onComplete() are called.
Clients may may receive 0 or more onResponse callbacks.
If an exception is thrown by an implementation the caller will terminate the stream by
calling ResponseObserver.onError(Throwable) with the caught exception as the cause.
This implementation simply delegates to onResponseImpl(Object) after ensuring
consistent state.
onResponse in interface ResponseObserver<V>response - the value passed to the streampublic final void onComplete()
May only be called once, and if called, it must be the last method called. In particular, if
an exception is thrown by an implementation of onComplete, no further calls to any
method are allowed.
This implementation simply delegates to onCompleteImpl() after ensuring consistent
state.
onComplete in interface ResponseObserver<V>public final void onError(Throwable t)
May only be called once, and if called, it must be the last method called. In particular, if
an exception is thrown by an implementation of onError, no further calls to any method
are allowed.
This implementation simply delegates to onErrorImpl(Throwable) after ensuring
consistent state.
onError in interface ResponseObserver<V>t - the error occurred on the streamprotected abstract void onStartImpl(StreamController controller)
onStart(StreamController)protected abstract void onResponseImpl(V response)
onResponse(Object)protected abstract void onErrorImpl(Throwable t)
onErrorImpl(Throwable)protected abstract void onCompleteImpl()
onComplete()