Session

<p>A {@link Session} represents the client-side endpoint of a HTTP/2 connection to a single origin server.</p> <p>Once a {@link Session} has been obtained, it can be used to open HTTP/2 streams:</p> <pre> Session session = ...; HeadersFrame frame = ...; Promise&lt;Stream&gt; promise = ... session.newStream(frame, promise, new Stream.Listener.Adapter() { void onHeaders(Stream stream, HeadersFrame frame) { // Reply received } }); </pre> <p>A {@link Session} is the active part of the endpoint, and by calling its API applications can generate events on the connection; conversely {@link Session.Listener} is the passive part of the endpoint, and has callbacks that are invoked when events happen on the connection.</p>

@see Session.Listener

Members

Functions

close
bool close(int error, string payload, Callback callback)

<p>Closes the session by sending a GOAWAY frame with the given error code and payload.</p> <p>The GOAWAY frame is sent only once; subsequent or concurrent attempts to close the session will have no effect.</p>

getStream
Stream getStream(int streamId)

<p>Retrieves the stream with the given {@code streamId}.</p>

getStreams
Stream[] getStreams()

@return a snapshot of all the streams currently belonging to this session

isClosed
bool isClosed()

@return whether the session is not open

newStream
void newStream(HeadersFrame frame, Promise!Stream promise, Stream.Listener listener)

<p>Sends the given HEADERS {@code frame} to create a new {@link Stream}.</p>

ping
void ping(PingFrame frame, Callback callback)

<p>Sends the given PING {@code frame}.</p> <p>PING frames may be used to test the connection integrity and to measure round-trip time.</p>

priority
int priority(PriorityFrame frame, Callback callback)

<p>Sends the given PRIORITY {@code frame}.</p> <p>If the {@code frame} references a {@code streamId} that does not exist (for example {@code 0}), then a new {@code streamId} will be allocated, to support <em>unused anchor streams</em> that act as parent for other streams.</p>

settings
void settings(SettingsFrame frame, Callback callback)

<p>Sends the given SETTINGS {@code frame} to configure the session.</p>

toString
string toString()
Undocumented in source.

Interfaces

Listener
interface Listener

<p>A {@link Listener} is the passive counterpart of a {@link Session} and receives events happening on a HTTP/2 connection.</p>

Meta