public abstract class HTTP2Session extends Object implements SessionSPI, Parser.Listener
Session.ListenerParser.Listener.Adapter| 构造器和说明 |
|---|
HTTP2Session(Scheduler scheduler,
Session endPoint,
Generator generator,
Session.Listener listener,
FlowControlStrategy flowControl,
int initialStreamId,
int streamIdleTimeout) |
| 限定符和类型 | 方法和说明 |
|---|---|
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 StreamSPI |
createLocalStream(int streamId,
Promise<Stream> promise) |
protected StreamSPI |
createRemoteStream(int streamId) |
void |
data(StreamSPI stream,
Callback callback,
DataFrame frame)
Enqueues the given DATA frame to be written to the connection.
|
void |
disconnect() |
void |
frames(StreamSPI stream,
Callback callback,
Frame frame,
Frame... frames)
Enqueues the given frames to be written to the connection.
|
Session |
getEndPoint() |
FlowControlStrategy |
getFlowControlStrategy() |
Generator |
getGenerator() |
int |
getInitialSessionRecvWindow() |
int |
getMaxLocalStreams() |
int |
getMaxRemoteStreams() |
int |
getRecvWindow() |
int |
getSendWindow() |
StreamSPI |
getStream(int streamId)
Retrieves the stream with the given
streamId. |
int |
getStreamCount() |
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 StreamSPI |
newStream(int streamId,
boolean local) |
protected void |
notifyClose(Session session,
GoAwayFrame frame) |
protected void |
notifyFailure(Session session,
Throwable failure) |
protected boolean |
notifyIdleTimeout(Session session) |
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) |
boolean |
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(StreamSPI 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. |
int |
priority(PriorityFrame frame,
Callback callback)
Sends the given PRIORITY
frame. |
void |
push(StreamSPI stream,
Promise<Stream> promise,
PushPromiseFrame frame,
Stream.Listener listener)
Enqueues the given PUSH_PROMISE frame to be written to the connection.
|
void |
removeStream(StreamSPI stream)
Removes the given
stream. |
protected void |
reset(ResetFrame frame,
Callback callback) |
void |
setInitialSessionRecvWindow(int initialSessionRecvWindow) |
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, waitonPushPromisepublic HTTP2Session(Scheduler scheduler, Session endPoint, Generator generator, Session.Listener listener, FlowControlStrategy flowControl, int initialStreamId, int streamIdleTimeout)
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 int getInitialSessionRecvWindow()
public void setInitialSessionRecvWindow(int initialSessionRecvWindow)
public Session getEndPoint()
public Generator getGenerator()
public void onData(DataFrame frame)
onData 在接口中 Parser.Listenerpublic abstract void onHeaders(HeadersFrame frame)
onHeaders 在接口中 Parser.Listenerpublic void onPriority(PriorityFrame frame)
onPriority 在接口中 Parser.Listenerpublic void onReset(ResetFrame frame)
onReset 在接口中 Parser.Listenerpublic void onSettings(SettingsFrame frame)
onSettings 在接口中 Parser.Listenerpublic void onSettings(SettingsFrame frame, boolean reply)
public void onPing(PingFrame frame)
onPing 在接口中 Parser.Listenerpublic void onGoAway(GoAwayFrame frame)
HTTP2Session.ControlEntry#succeeded()
* In all other cases, we do nothing since other methods are already
performing their actions.onGoAway 在接口中 Parser.Listenerframe - the GO_AWAY frame that has been received.close(int, String, Callback),
onShutdown(),
onIdleTimeout()public void onWindowUpdate(WindowUpdateFrame frame)
onWindowUpdate 在接口中 Parser.Listenerpublic void onConnectionFailure(int error,
String reason)
onConnectionFailure 在接口中 Parser.Listenerpublic void newStream(HeadersFrame frame, Promise<Stream> promise, Stream.Listener listener)
Session
Sends the given HEADERS frame to create a new Stream.
public int priority(PriorityFrame frame, Callback callback)
Session
Sends the given PRIORITY frame.
If the frame references a streamId that does not exist
(for example 0), then a new streamId will be allocated,
to support unused anchor streams that act as parent for other
streams.
public void push(StreamSPI stream, Promise<Stream> promise, PushPromiseFrame frame, Stream.Listener listener)
SessionSPIEnqueues the given PUSH_PROMISE frame to be written to the connection.
Differently from SessionSPI.frames(StreamSPI, Callback, Frame, Frame...),
this method generates atomically the stream id for the pushed stream.
push 在接口中 SessionSPIstream - 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 eventspublic 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 在接口中 Sessionerror - the error codereason - the reasoncallback - the callback to invoke when the operation is completeonGoAway(GoAwayFrame),
onShutdown(),
onIdleTimeout()public void frames(StreamSPI stream, Callback callback, Frame frame, Frame... frames)
SessionSPIEnqueues the given frames to be written to the connection.
frames 在接口中 SessionSPIstream - the stream the frames belong tocallback - the callback that gets notified when the frames have been sentframe - the first frame to enqueueframes - additional frames to enqueuepublic void data(StreamSPI stream, Callback callback, DataFrame frame)
SessionSPIEnqueues the given DATA frame to be written to the connection.
data 在接口中 SessionSPIstream - the stream the data frame belongs tocallback - the callback that gets notified when the frame has been sentframe - the DATA frame to sendprotected StreamSPI createRemoteStream(int streamId)
protected StreamSPI newStream(int streamId, boolean local)
public void removeStream(StreamSPI stream)
SessionSPI
Removes the given stream.
removeStream 在接口中 SessionSPIstream - the stream to removepublic Collection<Stream> getStreams()
getStreams 在接口中 Sessionpublic int getStreamCount()
public StreamSPI getStream(int streamId)
Session
Retrieves the stream with the given streamId.
getStream 在接口中 SessiongetStream 在接口中 SessionSPIstreamId - the stream id of the stream looked forpublic int getSendWindow()
public int getRecvWindow()
public int updateSendWindow(int delta)
SessionSPI
Updates the session send window by the given delta.
updateSendWindow 在接口中 SessionSPIdelta - the delta value (positive or negative) to add to the session
send windowpublic int updateRecvWindow(int delta)
SessionSPI
Updates the session receive window by the given delta.
updateRecvWindow 在接口中 SessionSPIdelta - the delta value (positive or negative) to add to the session
receive windowpublic void onWindowUpdate(StreamSPI stream, WindowUpdateFrame frame)
SessionSPICallback method invoked when a WINDOW_UPDATE frame has been received.
onWindowUpdate 在接口中 SessionSPIstream - 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 在接口中 SessionSPIpublic 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 在接口中 SessionSPIonGoAway(GoAwayFrame),
close(int, String, Callback),
onIdleTimeout()public boolean 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 在接口中 SessionSPIonGoAway(GoAwayFrame),
close(int, String, Callback),
onShutdown()public void onFrame(Frame frame)
SessionSPICallback method invoked during an HTTP/1.1 to HTTP/2 upgrade requests to process the given synthetic frame.
onFrame 在接口中 SessionSPIframe - the synthetic frame to processpublic 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)
protected boolean notifyIdleTimeout(Session session)
Copyright © 2016. All rights reserved.