public abstract class HTTP2Session extends Object implements ISession, Parser.Listener
Session.Listener
Parser.Listener.Adapter
Constructor and Description |
---|
HTTP2Session(Scheduler scheduler,
EndPoint endPoint,
Generator generator,
Session.Listener listener,
FlowControlStrategy flowControl,
int initialStreamId) |
Modifier and Type | Method and Description |
---|---|
protected void |
abort(Throwable failure) |
boolean |
close(int error,
String reason,
Callback callback)
Invoked internally and by applications to send a GO_AWAY frame to the
other peer.
|
protected IStream |
createLocalStream(int streamId,
Promise<Stream> promise) |
protected IStream |
createRemoteStream(int streamId) |
IStream |
createUpgradeStream() |
void |
data(IStream stream,
Callback callback,
DataFrame frame)
Enqueues the given DATA frame to be written to the connection.
|
void |
disconnect() |
void |
frames(IStream stream,
Callback callback,
Frame frame,
Frame... frames)
Enqueues the given frames to be written to the connection.
|
EndPoint |
getEndPoint() |
FlowControlStrategy |
getFlowControlStrategy() |
Generator |
getGenerator() |
int |
getMaxLocalStreams() |
int |
getMaxRemoteStreams() |
int |
getRecvWindow() |
int |
getSendWindow() |
IStream |
getStream(int streamId)
Retrieves the stream with the given
streamId . |
long |
getStreamIdleTimeout() |
Collection<Stream> |
getStreams() |
boolean |
isClosed() |
boolean |
isDisconnected() |
boolean |
isPushEnabled() |
void |
newStream(HeadersFrame frame,
Promise<Stream> promise,
Stream.Listener listener)
Sends the given HEADERS
frame to create a new Stream . |
protected IStream |
newStream(int streamId) |
protected void |
notifyClose(Session session,
GoAwayFrame frame) |
protected void |
notifyFailure(Session session,
Throwable failure) |
protected Stream.Listener |
notifyNewStream(Stream stream,
HeadersFrame frame) |
protected void |
notifyPing(Session session,
PingFrame frame) |
protected void |
notifyReset(Session session,
ResetFrame frame) |
protected void |
notifySettings(Session session,
SettingsFrame frame) |
void |
onConnectionFailure(int error,
String reason) |
void |
onData(DataFrame frame) |
void |
onFrame(Frame frame)
Callback method invoked during an HTTP/1.1 to HTTP/2 upgrade requests
to process the given synthetic frame.
|
void |
onGoAway(GoAwayFrame frame)
This method is called when receiving a GO_AWAY from the other peer.
|
abstract void |
onHeaders(HeadersFrame frame) |
void |
onIdleTimeout()
This method is invoked when the idle timeout triggers.
|
void |
onPing(PingFrame frame) |
void |
onPriority(PriorityFrame frame) |
void |
onReset(ResetFrame frame) |
void |
onSettings(SettingsFrame frame) |
void |
onSettings(SettingsFrame frame,
boolean reply) |
void |
onShutdown()
A typical close by a remote peer involves a GO_AWAY frame followed by TCP FIN.
|
void |
onWindowUpdate(IStream stream,
WindowUpdateFrame frame)
Callback method invoked when a WINDOW_UPDATE frame has been received.
|
void |
onWindowUpdate(WindowUpdateFrame frame) |
void |
ping(PingFrame frame,
Callback callback)
Sends the given PING
frame . |
void |
push(IStream stream,
Promise<Stream> promise,
PushPromiseFrame frame,
Stream.Listener listener)
Enqueues the given PUSH_PROMISE frame to be written to the connection.
|
void |
removeStream(IStream stream,
boolean local)
Removes the given
stream . |
protected void |
reset(ResetFrame frame,
Callback callback) |
void |
setMaxLocalStreams(int maxLocalStreams) |
void |
setMaxRemoteStreams(int maxRemoteStreams) |
void |
setStreamIdleTimeout(long streamIdleTimeout) |
void |
settings(SettingsFrame frame,
Callback callback)
Sends the given SETTINGS
frame to configure the session. |
String |
toString() |
int |
updateRecvWindow(int delta)
Updates the session receive window by the given
delta . |
int |
updateSendWindow(int delta)
Updates the session send window by the given
delta . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
onPushPromise
public HTTP2Session(Scheduler scheduler, EndPoint endPoint, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId)
public FlowControlStrategy getFlowControlStrategy()
public int getMaxLocalStreams()
public void setMaxLocalStreams(int maxLocalStreams)
public int getMaxRemoteStreams()
public void setMaxRemoteStreams(int maxRemoteStreams)
public long getStreamIdleTimeout()
public void setStreamIdleTimeout(long streamIdleTimeout)
public EndPoint getEndPoint()
public Generator getGenerator()
public void onData(DataFrame frame)
onData
in interface Parser.Listener
public abstract void onHeaders(HeadersFrame frame)
onHeaders
in interface Parser.Listener
public void onPriority(PriorityFrame frame)
onPriority
in interface Parser.Listener
public void onReset(ResetFrame frame)
onReset
in interface Parser.Listener
public void onSettings(SettingsFrame frame)
onSettings
in interface Parser.Listener
public void onSettings(SettingsFrame frame, boolean reply)
public void onPing(PingFrame frame)
onPing
in interface Parser.Listener
public void onGoAway(GoAwayFrame frame)
HTTP2Session.ControlEntry#succeeded()
* In all other cases, we do nothing since other methods are already
performing their actions.onGoAway
in interface Parser.Listener
frame
- the GO_AWAY frame that has been received.close(int, String, Callback)
,
onShutdown()
,
onIdleTimeout()
public void onWindowUpdate(WindowUpdateFrame frame)
onWindowUpdate
in interface Parser.Listener
public void onConnectionFailure(int error, String reason)
onConnectionFailure
in interface Parser.Listener
public void newStream(HeadersFrame frame, Promise<Stream> promise, Stream.Listener listener)
Session
Sends the given HEADERS frame
to create a new Stream
.
public void push(IStream stream, Promise<Stream> promise, PushPromiseFrame frame, Stream.Listener listener)
ISession
Enqueues the given PUSH_PROMISE frame to be written to the connection.
Differently from ISession.frames(IStream, Callback, Frame, Frame...)
, this method
generates atomically the stream id for the pushed stream.
public void settings(SettingsFrame frame, Callback callback)
Session
Sends the given SETTINGS frame
to configure the session.
public void ping(PingFrame frame, Callback callback)
Session
Sends the given PING frame
.
PING frames may be used to test the connection integrity and to measure round-trip time.
protected void reset(ResetFrame frame, Callback callback)
public boolean close(int error, String reason, Callback callback)
onShutdown()
.
Otherwise, the idle timeout mechanism will close the connection, see
onIdleTimeout()
.
* In all other cases, we do nothing since other methods are already
performing their actions.close
in interface Session
error
- the error codereason
- the reasoncallback
- the callback to invoke when the operation is completeonGoAway(GoAwayFrame)
,
onShutdown()
,
onIdleTimeout()
public boolean isClosed()
public void frames(IStream stream, Callback callback, Frame frame, Frame... frames)
ISession
Enqueues the given frames to be written to the connection.
public void data(IStream stream, Callback callback, DataFrame frame)
ISession
Enqueues the given DATA frame to be written to the connection.
protected IStream createRemoteStream(int streamId)
public IStream createUpgradeStream()
protected IStream newStream(int streamId)
public void removeStream(IStream stream, boolean local)
ISession
Removes the given stream
.
removeStream
in interface ISession
stream
- the stream to removelocal
- whether the stream is local or remotepublic Collection<Stream> getStreams()
getStreams
in interface Session
public IStream getStream(int streamId)
Session
Retrieves the stream with the given streamId
.
public int getSendWindow()
public int getRecvWindow()
public int updateSendWindow(int delta)
ISession
Updates the session send window by the given delta
.
updateSendWindow
in interface ISession
delta
- the delta value (positive or negative) to add to the session send windowpublic int updateRecvWindow(int delta)
ISession
Updates the session receive window by the given delta
.
updateRecvWindow
in interface ISession
delta
- the delta value (positive or negative) to add to the session receive windowpublic void onWindowUpdate(IStream stream, WindowUpdateFrame frame)
ISession
Callback method invoked when a WINDOW_UPDATE frame has been received.
onWindowUpdate
in interface ISession
stream
- the stream the window update belongs to, or null if the window update belongs to the sessionframe
- the WINDOW_UPDATE frame receivedpublic boolean isPushEnabled()
isPushEnabled
in interface ISession
public void onShutdown()
close(int, String, Callback)
.
* REMOTELY_CLOSED: we received the GO_AWAY, and the TCP FIN afterwards, so we
do nothing since the handling of the GO_AWAY will take care of closing the
connection. See onGoAway(GoAwayFrame)
.onShutdown
in interface ISession
onGoAway(GoAwayFrame)
,
close(int, String, Callback)
,
onIdleTimeout()
public void onIdleTimeout()
close(int, String, Callback)
.
* LOCALLY_CLOSED: we have sent a GO_AWAY and only shutdown the output, but the
other peer did not close the connection so we never received the TCP FIN, and
therefore we terminate.
* REMOTELY_CLOSED: the other peer sent us a GO_AWAY, we should have queued a
disconnect, but for some reason it was not processed (for example, queue was
stuck because of TCP congestion), therefore we terminate.
See onGoAway(GoAwayFrame)
.onIdleTimeout
in interface ISession
onGoAway(GoAwayFrame)
,
close(int, String, Callback)
,
onShutdown()
public void onFrame(Frame frame)
ISession
Callback method invoked during an HTTP/1.1 to HTTP/2 upgrade requests to process the given synthetic frame.
public void disconnect()
protected void abort(Throwable failure)
public boolean isDisconnected()
protected Stream.Listener notifyNewStream(Stream stream, HeadersFrame frame)
protected void notifySettings(Session session, SettingsFrame frame)
protected void notifyReset(Session session, ResetFrame frame)
protected void notifyClose(Session session, GoAwayFrame frame)
Copyright © 1995-2015 Webtide. All Rights Reserved.