Interface Http2SubProtocolSelector.SubProtocolHandler

Enclosing interface:
Http2SubProtocolSelector

public static interface Http2SubProtocolSelector.SubProtocolHandler
Handler of a sub-protocol.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Release resources when the stream handler exits or its connection closes, including after normal completion.
    void
    Data was received.
    void
    Called once the sub-protocol handler is available.
    default void
    Register a callback for when the handler reaches the closed state.
    default void
    Register a notifier that requests streamEvent() on the existing HTTP/2 stream thread.
    void
    RST stream was received, or the local connection closed before the subprotocol started.
    default void
    Process a requested event on the existing HTTP/2 stream thread.
    default void
    Finish application processing after stream closure when the HTTP/2 stream runner exits.
    Current stream state.
    void
    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 with init() 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 with init(), data(Http2FrameHeader, BufferData), and streamEvent(). This callback can occur even when the stream closes before init() is invoked. It may overlap close() or rstStream(Http2RstStream) on the connection thread. Implementations may block their own stream thread but must not write further frames. The default implementation does nothing.
    • streamState

      Http2StreamState streamState()
      Current stream state.
      Returns:
      stream state
    • onStreamClosed

      default void onStreamClosed(Runnable listener)
      Register a callback for when the handler reaches the closed state. 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

      default void onStreamEvent(Runnable notifier)
      Register a notifier that requests streamEvent() on the existing HTTP/2 stream thread. Registration happens before init(). 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 with init() and data(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

      void rstStream(Http2RstStream 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 before init(). Implementations must support both threads and concurrent invocation with init(). Implementations must not block the calling thread; application cancellation that can block belongs in streamFinished().
      Parameters:
      rstStream - RST stream frame
    • windowUpdate

      void windowUpdate(Http2WindowUpdate update)
      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

      void data(Http2FrameHeader header, BufferData data)
      Data was received. Always dispatched on the HTTP/2 stream thread. The data may be empty. Check the Http2FrameHeader.flags(io.helidon.http.http2.Http2FrameTypes) if this is Http2Flag.END_OF_STREAM to identify if this is the last data incoming.
      Parameters:
      header - frame header
      data - frame data