Interface ISession

All Superinterfaces:
Session
All Known Implementing Classes:
HTTP2ClientSession, HTTP2ServerSession, HTTP2Session

public interface ISession extends Session

The SPI interface for implementing an HTTP/2 session.

This class extends Session by adding the methods required to implement the HTTP/2 session functionalities.

  • Method Details

    • getStream

      IStream getStream(int streamId)
      Description copied from interface: Session

      Retrieves the stream with the given streamId.

      Specified by:
      getStream in interface Session
      Parameters:
      streamId - the stream id of the stream looked for
      Returns:
      the stream with the given id, or null if no such stream exist
    • removeStream

      boolean removeStream(IStream stream)

      Removes the given stream.

      Parameters:
      stream - the stream to remove
      Returns:
      whether the stream was removed
    • newStream

      void newStream(IStream.FrameList frames, Promise<Stream> promise, Stream.Listener listener)

      Sends the given list of frames to create a new Stream.

      Parameters:
      frames - the list of frames to send
      promise - the promise that gets notified of the stream creation
      listener - the listener that gets notified of stream events
    • frames

      void frames(IStream stream, List<? extends Frame> frames, Callback callback)

      Enqueues the given frames to be written to the connection.

      Parameters:
      stream - the stream the frames belong to
      frames - the frames to enqueue
      callback - the callback that gets notified when the frames have been sent
    • push

      void push(IStream stream, Promise<Stream> promise, PushPromiseFrame frame, Stream.Listener listener)

      Enqueues the given PUSH_PROMISE frame to be written to the connection.

      Differently from frames(IStream, List, Callback), this method generates atomically the stream id for the pushed stream.

      Parameters:
      stream - the stream associated to the pushed stream
      promise - the promise that gets notified of the pushed stream creation
      frame - the PUSH_PROMISE frame to enqueue
      listener - the listener that gets notified of pushed stream events
    • data

      void data(IStream stream, Callback callback, DataFrame frame)

      Enqueues the given DATA frame to be written to the connection.

      Parameters:
      stream - the stream the data frame belongs to
      callback - the callback that gets notified when the frame has been sent
      frame - the DATA frame to send
    • updateSendWindow

      int updateSendWindow(int delta)

      Updates the session send window by the given delta.

      Parameters:
      delta - the delta value (positive or negative) to add to the session send window
      Returns:
      the previous value of the session send window
    • updateRecvWindow

      int updateRecvWindow(int delta)

      Updates the session receive window by the given delta.

      Parameters:
      delta - the delta value (positive or negative) to add to the session receive window
      Returns:
      the previous value of the session receive window
    • onWindowUpdate

      void onWindowUpdate(IStream stream, WindowUpdateFrame frame)

      Callback method invoked when a WINDOW_UPDATE frame has been received.

      Parameters:
      stream - the stream the window update belongs to, or null if the window update belongs to the session
      frame - the WINDOW_UPDATE frame received
    • isPushEnabled

      boolean isPushEnabled()
      Returns:
      whether the push functionality is enabled
    • onShutdown

      void onShutdown()

      Callback invoked when the connection reads -1.

      See Also:
    • onIdleTimeout

      boolean onIdleTimeout()

      Callback invoked when the idle timeout expires.

      Returns:
      true if the session has expired
      See Also:
    • onFrame

      void onFrame(Frame frame)

      Callback method invoked during an HTTP/1.1 to HTTP/2 upgrade requests to process the given synthetic frame.

      Parameters:
      frame - the synthetic frame to process
    • onFlushed

      void onFlushed(long bytes) throws IOException

      Callback method invoked when bytes are flushed to the network.

      Parameters:
      bytes - the number of bytes flushed to the network
      Throws:
      IOException - if the flush should fail
    • getBytesWritten

      long getBytesWritten()
      Returns:
      the number of bytes written by this session
    • onData

      void onData(DataFrame frame, Callback callback)

      Callback method invoked when a DATA frame is received.

      Parameters:
      frame - the DATA frame received
      callback - the callback to notify when the frame has been processed
    • shutdown

      CompletableFuture<Void> shutdown()

      Gracefully closes the session, returning a CompletableFuture that is completed when all the streams currently being processed are completed.

      Implementation is idempotent, i.e. calling this method a second time or concurrently results in a no-operation.

      Returns:
      a CompletableFuture that is completed when all the streams are completed