Interface Http2SubProtocolSelector.SubProtocolHandler
- Enclosing interface:
Http2SubProtocolSelector
public static interface Http2SubProtocolSelector.SubProtocolHandler
Handler of a sub-protocol.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()Release resources when the stream handler exits or its connection closes, including after normal completion.voiddata(Http2FrameHeader header, BufferData data) Data was received.voidinit()Called once the sub-protocol handler is available.default voidonStreamClosed(Runnable listener) Register a callback for when the handler reaches theclosedstate.default voidonStreamEvent(Runnable notifier) Register a notifier that requestsstreamEvent()on the existing HTTP/2 stream thread.voidrstStream(Http2RstStream rstStream) RST stream was received, or the local connection closed before the subprotocol started.default voidProcess a requested event on the existing HTTP/2 stream thread.default voidFinish application processing after stream closure when the HTTP/2 stream runner exits.Current stream state.voidwindowUpdate(Http2WindowUpdate update) Window update was received.
-
Method Details
-
init
void init()Called once the sub-protocol handler is available. Always dispatched on the HTTP/2 stream thread. -
close
default void close()Release resources when the stream handler exits or its connection closes, including after normal completion. Called at most once for this stream, on either the HTTP/2 connection thread or the stream thread. This may happen before or concurrently withinit()or other callbacks. Implementations must tolerate an already completed or cancelled operation and must not block the calling thread or write further frames. The default implementation does nothing. -
streamFinished
default void streamFinished()Finish application processing after stream closure when the HTTP/2 stream runner exits. Called at most once on the existing HTTP/2 stream thread, serialized withinit(),data(Http2FrameHeader, BufferData), andstreamEvent(). This callback can occur even when the stream closes beforeinit()is invoked. It may overlapclose()orrstStream(Http2RstStream)on the connection thread. Implementations may block their own stream thread but must not write further frames. The default implementation does nothing. -
streamState
-
onStreamClosed
Register a callback for when the handler reaches theclosedstate. Implementations that can close asynchronously must override this method and invoke the callback exactly once. The callback may run on any thread. The default implementation validates the callback but does not register it.- Parameters:
listener- close listener
-
onStreamEvent
Register a notifier that requestsstreamEvent()on the existing HTTP/2 stream thread. Registration happens beforeinit(). The notifier may be called from any thread and does not wait for the callback. Repeated notifications coalesce into one pending event per stream; a notification during a callback requests a subsequent callback. Notifications after stream closure are ignored. Events remain available after the remote peer ends its request, while the local stream is still open. The default implementation validates the notifier but does not retain it.- Parameters:
notifier- stream event notifier
-
streamEvent
default void streamEvent()Process a requested event on the existing HTTP/2 stream thread. This callback is serialized withinit()anddata(Http2FrameHeader, BufferData). An event carries no inbound DATA and consumes no flow-control credit. The callback may block, delaying subsequent callbacks on this stream. The default implementation does nothing. -
rstStream
RST stream was received, or the local connection closed before the subprotocol started. This method is normally dispatched on the HTTP/2 connection thread. If the stream closes while subprotocol selection is in progress, it is dispatched on the stream thread beforeinit(). Implementations must support both threads and concurrent invocation withinit(). Implementations must not block the calling thread; application cancellation that can block belongs instreamFinished().- Parameters:
rstStream- RST stream frame
-
windowUpdate
Window update was received. Note that this method will be dispatched on the HTTP/2 connection thread, not the stream thread.- Parameters:
update- window update frame
-
data
Data was received. Always dispatched on the HTTP/2 stream thread. The data may be empty. Check theHttp2FrameHeader.flags(io.helidon.http.http2.Http2FrameTypes)if this isHttp2Flag.END_OF_STREAMto identify if this is the last data incoming.- Parameters:
header- frame headerdata- frame data
-