Interface ISession
- All Superinterfaces:
Session
- All Known Implementing Classes:
HTTP2ClientSession,HTTP2ServerSession,HTTP2Session
The SPI interface for implementing an HTTP/2 session.
This class extends Session by adding the methods required to
implement the HTTP/2 session functionalities.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.http2.api.Session
Session.Listener -
Method Summary
Modifier and TypeMethodDescriptionvoidEnqueues the given DATA frame to be written to the connection.voidEnqueues the given frames to be written to the connection.longgetStream(int streamId) Retrieves the stream with the givenstreamId.booleanvoidnewStream(IStream.FrameList frames, Promise<Stream> promise, Stream.Listener listener) Sends the given list of frames to create a newStream.voidCallback method invoked when a DATA frame is received.voidonFlushed(long bytes) Callback method invoked when bytes are flushed to the network.voidCallback method invoked during an HTTP/1.1 to HTTP/2 upgrade requests to process the given synthetic frame.booleanCallback invoked when the idle timeout expires.voidCallback invoked when the connection reads -1.voidonWindowUpdate(IStream stream, WindowUpdateFrame frame) Callback method invoked when a WINDOW_UPDATE frame has been received.voidpush(IStream stream, Promise<Stream> promise, PushPromiseFrame frame, Stream.Listener listener) Enqueues the given PUSH_PROMISE frame to be written to the connection.booleanremoveStream(IStream stream) Removes the givenstream.shutdown()Gracefully closes the session, returning aCompletableFuturethat is completed when all the streams currently being processed are completed.intupdateRecvWindow(int delta) Updates the session receive window by the givendelta.intupdateSendWindow(int delta) Updates the session send window by the givendelta.Methods inherited from interface org.eclipse.jetty.http2.api.Session
close, getLocalAddress, getLocalSocketAddress, getRemoteAddress, getRemoteSocketAddress, getStreams, isClosed, newStream, newStream, ping, priority, settings
-
Method Details
-
getStream
Description copied from interface:SessionRetrieves the stream with the given
streamId. -
removeStream
Removes the given
stream.- Parameters:
stream- the stream to remove- Returns:
- whether the stream was removed
-
newStream
Sends the given list of frames to create a new
Stream.- Parameters:
frames- the list of frames to sendpromise- the promise that gets notified of the stream creationlistener- the listener that gets notified of stream events
-
frames
Enqueues the given frames to be written to the connection.
- Parameters:
stream- the stream the frames belong toframes- the frames to enqueuecallback- the callback that gets notified when the frames have been sent
-
push
void push(IStream stream, Promise<Stream> promise, PushPromiseFrame frame, Stream.Listener listener) Enqueues the given PUSH_PROMISE frame to be written to the connection.
Differently from
frames(IStream, List, Callback), this method generates atomically the stream id for the pushed stream.- Parameters:
stream- the stream associated to the pushed streampromise- the promise that gets notified of the pushed stream creationframe- the PUSH_PROMISE frame to enqueuelistener- the listener that gets notified of pushed stream events
-
data
Enqueues the given DATA frame to be written to the connection.
- Parameters:
stream- the stream the data frame belongs tocallback- the callback that gets notified when the frame has been sentframe- the DATA frame to send
-
updateSendWindow
int updateSendWindow(int delta) Updates the session send window by the given
delta.- Parameters:
delta- the delta value (positive or negative) to add to the session send window- Returns:
- the previous value of the session send window
-
updateRecvWindow
int updateRecvWindow(int delta) Updates the session receive window by the given
delta.- Parameters:
delta- the delta value (positive or negative) to add to the session receive window- Returns:
- the previous value of the session receive window
-
onWindowUpdate
Callback method invoked when a WINDOW_UPDATE frame has been received.
- Parameters:
stream- the stream the window update belongs to, or null if the window update belongs to the sessionframe- the WINDOW_UPDATE frame received
-
isPushEnabled
boolean isPushEnabled()- Returns:
- whether the push functionality is enabled
-
onShutdown
void onShutdown()Callback invoked when the connection reads -1.
-
onIdleTimeout
boolean onIdleTimeout()Callback invoked when the idle timeout expires.
- Returns:
trueif the session has expired- See Also:
-
onFrame
Callback method invoked during an HTTP/1.1 to HTTP/2 upgrade requests to process the given synthetic frame.
- Parameters:
frame- the synthetic frame to process
-
onFlushed
Callback method invoked when bytes are flushed to the network.
- Parameters:
bytes- the number of bytes flushed to the network- Throws:
IOException- if the flush should fail
-
getBytesWritten
long getBytesWritten()- Returns:
- the number of bytes written by this session
-
onData
Callback method invoked when a DATA frame is received.
- Parameters:
frame- the DATA frame receivedcallback- the callback to notify when the frame has been processed
-
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
-