Class ProtocolStreamListener
- All Implemented Interfaces:
EventListener
,Stream.Listener
- Direct Known Subclasses:
ProtocolStreamListener.Client
,ProtocolStreamListener.Server
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract StreamEndPoint
void
onDataAvailable
(Stream stream) Callback method invoked when the application has expresseddemand
for data carried by STREAM frames, and there are STREAM frames available.void
Invoked when a stream failure is detected.void
onIdleTimeout
(Stream stream, TimeoutException failure, Promise.Invocable<Boolean> promise) Invoked when the stream is idle for longer than the idle timeout.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.quic.api.Stream.Listener
onClose, onDataBlocked, onMaxData, onNewStream, onReset, onStopSending
-
Constructor Details
-
ProtocolStreamListener
public ProtocolStreamListener()
-
-
Method Details
-
getStreamEndPoint
-
onDataAvailable
Description copied from interface:Stream.Listener
Callback method invoked when the application has expressed
demand
for data carried by STREAM frames, and there are STREAM frames available.Server applications should typically demand from
Stream.Listener.onNewStream(Stream, Frame.WithStreamId)
(upon receiving the first stream frame), while client applications should typically demand after obtaining aStream
viaSession.newStream(long, Listener)
.Just prior calling this method, the outstanding demand is cancelled; applications that implement this method should read content calling
Stream.read()
, and callStream.demand()
to signal to the implementation to call again this method when there may be more data available.Only one thread at a time invokes this method, although it may not be the same thread across different invocations.
It is always guaranteed that invoking
Stream.demand()
from within this method will not cause aStackOverflowError
.Typical usage:
class MyStreamListener implements Stream.Listener { @Override public void onDataAvailable(Stream stream) { while (true) { // Read a chunk of the content. Content.Chunk chunk = stream.read(); if (chunk == null) { // No data available now, demand to be called back. stream.demand(); return; } // Process the content chunk. process(chunk); // Notify that the content has been consumed. chunk.release(); if (chunk.isLast()) { // All data has been processed. return; } } } }
- Specified by:
onDataAvailable
in interfaceStream.Listener
- Parameters:
stream
- the stream- See Also:
-
onIdleTimeout
public void onIdleTimeout(Stream stream, TimeoutException failure, Promise.Invocable<Boolean> promise) Description copied from interface:Stream.Listener
Invoked when the stream is idle for longer than the idle timeout.
- Specified by:
onIdleTimeout
in interfaceStream.Listener
- Parameters:
stream
- the streamfailure
- the idle timeout failurepromise
- the promise to complete to notify the other peer that this stream is closing
-
onFailure
Description copied from interface:Stream.Listener
Invoked when a stream failure is detected.
- Specified by:
onFailure
in interfaceStream.Listener
- Parameters:
stream
- the streamfailure
- the stream failure
-