Class QuicheSession

All Implemented Interfaces:
Session, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle

public abstract class QuicheSession extends AbstractSession

Represents a logical connection with a remote peer, identified by a QUIC connection id.

Bytes received from a QuicheConnection in feed(SocketAddress, ByteBuffer) are passed to Quiche for processing; in turn, Quiche produces a list of QUIC stream ids that have pending I/O events, either read-ready or write-ready.

On the receive side, a QuicheSession fans-out to multiple QuicheStreams.

On the send side, many QuicheStreams fan-in to a QuicheSession.

See Also:
  • Constructor Details

  • Method Details

    • getScheduler

      public Scheduler getScheduler()
    • getByteBufferPool

      public ByteBufferPool getByteBufferPool()
    • getConnection

      protected QuicheConnection getConnection()
    • getNegotiatedProtocol

      public String getNegotiatedProtocol()
    • getId

      public String getId()
      Returns:
      the QUIC connection id
    • newStream

      public Stream newStream(long streamId, Stream.Listener listener)
      Description copied from interface: Session

      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

      public QuicheStream getStream(long streamId)
      Parameters:
      streamId - the stream id
      Returns:
      the QUIC stream with the given stream id
    • getStreams

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

      public void maxStreams(MaxStreamsFrame frame, Promise.Invocable<Session> promise)
      Description copied from interface: Session

      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

      public void ping(Promise.Invocable<Session> promise)
      Description copied from interface: Session

      Sends a PING frame on this connection.

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

      public void maxData(MaxDataFrame frame, Promise.Invocable<Session> promise)
      Description copied from interface: Session

      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
    • disconnect

      public void disconnect(ConnectionCloseFrame frame, Throwable failure, Promise.Invocable<Session> promise)
      Description copied from interface: Session

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

      Differently from Session.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
    • getLocalSocketAddress

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

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

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

      public long getIdleTimeout()
      Returns:
      the idle timeout in milliseconds
    • setIdleTimeout

      public void setIdleTimeout(long idleTimeout)
    • onIdleTimeout

      public boolean onIdleTimeout(TimeoutException timeout)
    • getConnectionId

      public QuicheConnectionId getConnectionId()
    • setConnectionId

      public void setConnectionId(QuicheConnectionId connectionId)
    • feed

      public void feed(SocketAddress remoteAddress, ByteBuffer cipherBuffer) throws IOException
      Throws:
      IOException
    • isConnectionEstablished

      public boolean isConnectionEstablished()
    • getPeerCertificates

      public X509Certificate[] getPeerCertificates()

      Returns the peer certificates chain.

      Due to current Quiche C API limitations (that the Rust version does not have), only the last certificate in the chain is returned. This may change in the future when the C APIs are aligned to the Rust APIs.

      Specified by:
      getPeerCertificates in class AbstractSession
      Returns:
      the peer certificates chain (currently only the last certificate in the chain)
    • produce

      public void produce()
    • data

      protected int data(QuicheStream stream, boolean last, ByteBuffer buffer) throws IOException
      Throws:
      IOException
    • offerTask

      public void offerTask(Runnable task)
      Specified by:
      offerTask in class AbstractSession
    • flush

      public void flush()
    • isOpen

      public boolean isOpen()
    • open

      public void open()