@BetaApi(value="The surface for streaming is not stable yet and may change in the future.") public interface StreamController
ResponseObserverto 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
|Modifier and Type||Method and Description|
Cancel the stream early.
Disables automatic flow control.
Requests up to the given number of responses from the call to be delivered to
This will manifest as an onError on the
ResponseObserver with the cause being a
void request(int count)
ResponseObserver.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.
count- the requested number of messages to be delivered to the listener. Must be non-negative.