Interface Session

All Known Implementing Classes:
AbstractSession, QuicheSession

public interface Session

Represents a QUIC connection to a remote peer.

A Session represents the active part of the connection, and by calling its APIs applications can generate events on the connection.

Conversely, Session.Listener is the passive part of the connection, and has callback methods that are invoked when events happen on the connection.

  • Method Details

    • getId

      String getId()
      Returns:
      the QUIC connection id
    • newStreamId

      long newStreamId(boolean bidirectional)

      Creates a new QUIC stream id, with the given directionality.

      Parameters:
      bidirectional - whether the stream is bidirectional or unidirectional
      Returns:
      a new QUIC stream id
    • newStream

      Stream newStream(long streamId, Stream.Listener listener)

      Creates a new local QUIC stream with the given stream id and listener.

      Parameters:
      streamId - the QUIC stream id
      listener - the listener of stream events
      Returns:
      a new local QUIC stream
    • getStream

      Stream getStream(long streamId)
      Parameters:
      streamId - the stream id
      Returns:
      the QUIC stream with the given stream id
    • maxStreams

      void maxStreams(MaxStreamsFrame frame, Promise.Invocable<Session> promise)

      Sends a MAX_STREAMS frame on this connection.

      Parameters:
      frame - the frame to send
      promise - the Promise.Invocable that gets notified when the frame has been sent
    • ping

      void ping(Promise.Invocable<Session> promise)

      Sends a PING frame on this connection.

      Parameters:
      promise - the Promise.Invocable that gets notified when the frame has been sent
    • maxData

      void maxData(MaxDataFrame frame, Promise.Invocable<Session> promise)

      Sends a MAX_DATA frame on this connection.

      Parameters:
      frame - the frame to send
      promise - the Promise.Invocable that gets notified when the frame has been sent
    • close

      void close(ConnectionCloseFrame frame, Promise.Invocable<Session> promise)

      Closes this session with the given CONNECTION_CLOSE frame.

      Applications should use this method in conjunction with ConnectionCloseFrame(long, String).

      Differently from disconnect(ConnectionCloseFrame, Throwable, Promise.Invocable), this method performs close actions inwards, towards the application, that may perform additional actions such as writing to the network, for example close frames for a protocol on top of QUIC.

      After finishing the inward actions, disconnect(ConnectionCloseFrame, Throwable, Promise.Invocable) should be called to perform close actions outwards and eventually send the QUIC close frame and finally disconnect at the network level, if necessary.

      Parameters:
      frame - the frame carrying the error code and reason
      promise - the Callback that gets notified when the close is complete
    • disconnect

      void disconnect(ConnectionCloseFrame frame, Throwable failure, Promise.Invocable<Session> promise)

      Disconnects this session, with the given CONNECTION_CLOSE and failure cause, if any.

      Differently from close(ConnectionCloseFrame, Promise.Invocable), this method performs disconnect actions outwards, towards the network: typically clean-up actions and eventually sends the given QUIC close frame and finally disconnect at the network level, if necessary.

      Parameters:
      frame - the frame carrying the error code and reason
      failure - the failure that caused the disconnect, or null
      promise - the Promise.Invocable that gets notified when the disconnect is complete
    • getStreams

      Collection<Stream> getStreams()
      Returns:
      the QUIC streams managed by this session
    • getLocalSocketAddress

      SocketAddress getLocalSocketAddress()
      Returns:
      the local SocketAddress associated with this session
    • getRemoteSocketAddress

      SocketAddress getRemoteSocketAddress()
      Returns:
      the remote SocketAddress associated with this session
    • getLocalBidirectionalMaxStreams

      long getLocalBidirectionalMaxStreams()
      Returns:
      the local bidirectional streams max count
    • getIdleTimeout

      long getIdleTimeout()
      Returns:
      the idle timeout in milliseconds