Interface Stream
- All Known Implementing Classes:
 AbstractStream, QuicheStream
A stream represents a unidirectional or bidirectional exchange
of data within a Session.
Streams are multiplexed within a session, that is there can be multiple, different, concurrent streams present in a session.
Stream is the active part and by calling its API applications
can generate events on the stream.
Conversely, Stream.Listener is the passive part, and its
methods are invoked when events happen on the stream.
- See Also:
 
- 
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAStream.Listeneris the passive counterpart of aStreamand receives events, triggered by the remote peer, happening on stream. - 
Method Summary
Modifier and TypeMethodDescriptionvoiddata(boolean last, List<ByteBuffer> data, Promise.Invocable<Stream> promise) Sends a STREAM frame with the given data bytes and the indication of whether they are the last to be sent.voiddataBlocked(long offset, Promise.Invocable<Stream> promise) Sends a STREAM_DATA_BLOCKED frame, with the given offset.voiddemand()Demands more data bytes for this stream.voiddisconnect(long appErrorCode, Throwable failure, Promise.Invocable<Stream> promise) Abruptly terminates this stream with the given error.longgetId()Returns the stream id.longReturns theSessionthis stream is associated to.booleanReturns whether the stream is bidirectional.booleanisClosed()Returns whether the stream is fully closed, both locally and remotely.booleanisLocal()Returns whether the stream has been created locally or remotely.booleanReturns whether the stream is locally closed.booleanReturns whether the stream is remotely closed.voidmaxData(long maxData, Promise.Invocable<Stream> promise) Sends a MAX_STREAM_DATA frame with the new total max data bytes that this peer is willing to receive.read()Reads data from this stream, if any.voidreset(long appErrorCode, Promise.Invocable<Stream> promise) Sends a RESET_STREAM frame, with the given application error code.voidsetIdleTimeout(long idleTimeout) voidstopSending(long appErrorCode, Promise.Invocable<Stream> promise) Sends a STOP_SENDING frame, with the given application error code. 
- 
Method Details
- 
getId
long getId()Returns the stream id.
- Returns:
 - the stream id
 
 - 
isBidirectional
boolean isBidirectional()Returns whether the stream is bidirectional.
- Returns:
 - whether the stream is bidirectional
 
 - 
isLocal
boolean isLocal()Returns whether the stream has been created locally or remotely.
- Returns:
 - whether the stream is local or remote
 
 - 
isClosed
boolean isClosed()Returns whether the stream is fully closed, both locally and remotely.
- Returns:
 - whether the stream is fully closed
 - See Also:
 
 - 
isLocallyClosed
boolean isLocallyClosed()Returns whether the stream is locally closed.
A locally closed stream will not send further data.
A stream becomes locally closed when either it has sent
the last data, or issued areset(long, Promise.Invocable).- Returns:
 - whether the stream is locally closed
 - See Also:
 
 - 
isRemotelyClosed
boolean isRemotelyClosed()Returns whether the stream is remotely closed.
A remotely closed stream will not receive further data.
A stream becomes remotely closed when it has
read()the last data.- Returns:
 - whether the stream is remotely closed
 - See Also:
 
 - 
getIdleTimeout
long getIdleTimeout() - 
setIdleTimeout
void setIdleTimeout(long idleTimeout)  - 
getSession
 - 
read
Content.Chunk read()Reads data from this stream, if any.
The returned
Content.Chunkobject may benullindicating that the end of the read side of the stream has not yet been reached, which may happen when not all the bytes have been received so far, for example the remote peer did not send them yet, or they are in-flight.When the returned
Content.Chunkobject is notnull, the flow control window has been enlarged by the data length. Applications must call, either immediately or later (even asynchronously from a different thread)Retainable.release()to notify the implementation that the bytes have been processed.Content.Chunkobjects may be stored away for later, asynchronous, processing (for example, to process them only when all of them have been received).Once the returned
Content.Chunkobject indicates that the end of the read side of the stream has been reached, further calls to this method will return aContent.Chunkobject with the same indication, although the instance may be different.- Returns:
 - a 
Content.Chunkobject containing the data bytes or a failure, ornullif no data bytes are available - See Also:
 
 - 
demand
void demand()Demands more data bytes for this stream.
Calling this method causes
Stream.Listener.onDataAvailable(Stream, boolean)to be invoked, possibly at a later time, when the stream has data to be read, but also when the stream has reached EOF.This method is idempotent: calling it when there already is an outstanding demand to invoke
Stream.Listener.onDataAvailable(Stream, boolean)is a no-operation.The thread invoking this method may invoke directly
Stream.Listener.onDataAvailable(Stream, boolean), unless another thread that must invokeStream.Listener.onDataAvailable(Stream, boolean)notices the outstanding demand first.It is always guaranteed that invoking this method from within
onDataAvailable(Stream)will not cause aStackOverflowError.- See Also:
 
 - 
data
Sends a STREAM frame with the given data bytes and the indication of whether they are the last to be sent.
- Parameters:
 last- whether the data bytes are the lastdata- the list of data bytes to sendpromise- thePromise.Invocablethat gets notified when the data has been sent
 - 
maxData
Sends a MAX_STREAM_DATA frame with the new total max data bytes that this peer is willing to receive.
- Parameters:
 maxData- the max data bytes this peer is willing to receivepromise- thePromise.Invocablethat gets notified when the frame has been sent
 - 
reset
Sends a RESET_STREAM frame, with the given application error code.
- Parameters:
 appErrorCode- the application error codepromise- thePromise.Invocablethat gets notified when the frame has been sent
 - 
stopSending
Sends a STOP_SENDING frame, with the given application error code.
- Parameters:
 appErrorCode- the application error codepromise- thePromise.Invocablethat gets notified when the frame has been sent
 - 
dataBlocked
Sends a STREAM_DATA_BLOCKED frame, with the given offset.
- Parameters:
 offset- the data offsetpromise- thePromise.Invocablethat gets notified when the frame has been sent
 - 
disconnect
Abruptly terminates this stream with the given error.
This method removes this stream from its session and then terminates the QUIC stream, via
stopSending(long, Promise.Invocable), and then areset(long, Promise.Invocable).- Parameters:
 appErrorCode- the application error codefailure- the failure that caused the disconnect of the streampromise- thePromise.Invocablethat gets notified when the disconnect is completed
 
 -