Interface Session
- All Known Implementing Classes:
AbstractSession
,QuicheSession
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.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
ASession.Listener
is the passive counterpart of aSession
and receives events happening on an QUIC connection. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close
(ConnectionCloseFrame frame, Promise.Invocable<Session> promise) Closes this session with the givenCONNECTION_CLOSE
frame.void
disconnect
(ConnectionCloseFrame frame, Throwable failure, Promise.Invocable<Session> promise) Disconnects this session, with the givenCONNECTION_CLOSE
and failure cause, if any.getId()
long
long
getStream
(long streamId) void
maxData
(MaxDataFrame frame, Promise.Invocable<Session> promise) Sends a MAX_DATA frame on this connection.void
maxStreams
(MaxStreamsFrame frame, Promise.Invocable<Session> promise) Sends a MAX_STREAMS frame on this connection.newStream
(long streamId, Stream.Listener listener) Creates a new local QUIC stream with the given stream id and listener.long
newStreamId
(boolean bidirectional) Creates a new QUIC stream id, with the given directionality.void
ping
(Promise.Invocable<Session> promise) Sends a PING frame on this 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
Creates a new local QUIC stream with the given stream id and listener.
- Parameters:
streamId
- the QUIC stream idlistener
- the listener of stream events- Returns:
- a new local QUIC stream
-
getStream
- Parameters:
streamId
- the stream id- Returns:
- the QUIC stream with the given stream id
-
maxStreams
Sends a MAX_STREAMS frame on this connection.
- Parameters:
frame
- the frame to sendpromise
- thePromise.Invocable
that gets notified when the frame has been sent
-
ping
Sends a PING frame on this connection.
- Parameters:
promise
- thePromise.Invocable
that gets notified when the frame has been sent
-
maxData
Sends a MAX_DATA frame on this connection.
- Parameters:
frame
- the frame to sendpromise
- thePromise.Invocable
that gets notified when the frame has been sent
-
close
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 reasonpromise
- theCallback
that gets notified when the close is complete
-
disconnect
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 reasonfailure
- the failure that caused the disconnect, ornull
promise
- thePromise.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
-