Interface Session
- All Known Implementing Classes:
 HTTP2Session
A Session represents the client-side endpoint of an HTTP/2 connection to a single origin server.
Once a Session has been obtained, it can be used to open HTTP/2 streams:
Session session = ...;
HeadersFrame frame = ...;
Promise<Stream> promise = ...
session.newStream(frame, promise, new Stream.Listener()
{
    public void onHeaders(Stream stream, HeadersFrame frame)
    {
        // Reply received
    }
});
A Session is the active part of the endpoint, and by calling its API applications can generate
events on the connection; conversely Session.Listener is the passive part of the endpoint, and
has callbacks that are invoked when events happen on the connection.
- See Also:
 
- 
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceASession.Listeneris the passive counterpart of aSessionand receives events happening on an HTTP/2 connection. - 
Method Summary
Modifier and TypeMethodDescriptionbooleanCloses the session by sending a GOAWAY frame with the given error code and payload.Deprecated.default SocketAddressDeprecated.usegetRemoteSocketAddress()insteaddefault SocketAddressgetStream(int streamId) Retrieves the stream with the givenstreamId.booleanisClosed()booleandefault CompletableFuture<Stream> newStream(HeadersFrame frame, Stream.Listener listener) Sends the given HEADERSframeto create a newStream.voidnewStream(HeadersFrame frame, Promise<Stream> promise, Stream.Listener listener) Sends the given HEADERSframeto create a newStream.voidSends the given PINGframe.intpriority(PriorityFrame frame, Callback callback) Sends the given PRIORITYframe.default CompletableFuture<Void> settings(SettingsFrame frame) Sends the given SETTINGSframeto configure the session.voidsettings(SettingsFrame frame, Callback callback) Sends the given SETTINGSframeto configure the session.shutdown()Gracefully closes the session, returning aCompletableFuturethat is completed when all the streams currently being processed are completed. 
- 
Method Details
- 
newStream
Sends the given HEADERS
frameto create a newStream.- Parameters:
 frame- the HEADERS frame containing the HTTP headerslistener- the listener that gets notified of stream events- Returns:
 - a CompletableFuture that is notified of the stream creation
 
 - 
newStream
Sends the given HEADERS
frameto create a newStream.- Parameters:
 frame- the HEADERS frame containing the HTTP headerspromise- the promise that gets notified of the stream creationlistener- the listener that gets notified of stream events
 - 
priority
Sends the given PRIORITY
frame.If the
framereferences astreamIdthat does not exist (for example0), then a newstreamIdwill be allocated, to support unused anchor streams that act as parent for other streams.- Parameters:
 frame- the PRIORITY frame to sendcallback- the callback that gets notified when the frame has been sent- Returns:
 - the new stream id generated by the PRIORITY frame, or the stream id that it is already referencing
 
 - 
settings
Sends the given SETTINGS
frameto configure the session.- Parameters:
 frame- the SETTINGS frame to send- Returns:
 - a CompletableFuture that is notified when the frame has been sent
 
 - 
settings
Sends the given SETTINGS
frameto configure the session.- Parameters:
 frame- the SETTINGS frame to sendcallback- the callback that gets notified when the frame has been sent
 - 
ping
 - 
close
Closes the session by sending a GOAWAY frame with the given error code and payload.
- Parameters:
 error- the error codepayload- an optional payload (may be null)callback- the callback that gets notified when the frame has been sent- Returns:
 - true if the frame is being sent, false if the session was already closed
 
 - 
isClosed
boolean isClosed()- Returns:
 - whether the session is not open
 
 - 
isPushEnabled
boolean isPushEnabled()- Returns:
 - whether the push functionality is enabled
 
 - 
getStreams
Collection<Stream> getStreams()- Returns:
 - a snapshot of all the streams currently belonging to this session
 
 - 
getStream
Retrieves the stream with the given
streamId.- Parameters:
 streamId- the stream id of the stream looked for- Returns:
 - the stream with the given id, or null if no such stream exist
 
 - 
getLocalAddress
Deprecated.usegetLocalSocketAddress()instead- Returns:
 - the local network address this session is bound to,
or 
nullif this session is not bound to a network address 
 - 
getLocalSocketAddress
- Returns:
 - the local network address this session is bound to,
or 
nullif this session is not bound to a network address 
 - 
getRemoteAddress
Deprecated.usegetRemoteSocketAddress()instead- Returns:
 - the remote network address this session is connected to,
or 
nullif this session is not connected to a network address 
 - 
getRemoteSocketAddress
- Returns:
 - the remote network address this session is connected to,
or 
nullif this session is not connected to a network address 
 - 
shutdown
CompletableFuture<Void> shutdown()Gracefully closes the session, returning a
CompletableFuturethat 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 
CompletableFuturethat is completed when all the streams are completed 
 
 - 
 
getLocalSocketAddress()instead