Interface StreamController
-
public interface StreamControllerAllows the implementer ofResponseObserverto control the flow of responses.An instance of this class will be passed to
ResponseObserver.onStart(StreamController), at which point the receiver can disable automatic flow control. The receiver can also save a reference to the instance and terminate the stream early usingcancel().
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcancel()Cancel the stream early.voiddisableAutoInboundFlowControl()Disables automatic flow control.voidrequest(int count)Requests up to the given number of responses from the call to be delivered toResponseObserver.onResponse(Object).
-
-
-
Method Detail
-
cancel
void cancel()
Cancel the stream early.This will manifest as an onError on the
ResponseObserverwith the cause being aCancellationException.
-
disableAutoInboundFlowControl
void disableAutoInboundFlowControl()
Disables automatic flow control.The next response is requested immediately after the current response is processed by
ResponseObserver.onResponse(Object). If disabled, an application must make explicit calls torequest(int)to receive messages.
-
request
void request(int count)
Requests up to the given number of responses from the call to be delivered toResponseObserver.onResponse(Object). No additional messages will be delivered.This method can only be called after disabling automatic flow control.
Message delivery is guaranteed to be sequential in the order received. In addition, the listener methods will not be accessed concurrently. While it is not guaranteed that the same thread will always be used, it is guaranteed that only a single thread will access the listener at a time.
If called multiple times, the number of messages able to delivered will be the sum of the calls.
This method is safe to call from multiple threads without external synchronizaton.
- Parameters:
count- the requested number of messages to be delivered to the listener. Must be non-negative.
-
-