-
- All Known Implementing Classes:
DefaultHttp2Connection
@UnstableApi public interface Http2Connection
Manager for the state of an HTTP/2 connection with the remote end-point.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceHttp2Connection.Endpoint<F extends Http2FlowController>A view of the connection from one endpoint (local or remote).static interfaceHttp2Connection.ListenerListener for life-cycle events for streams in this connection.static interfaceHttp2Connection.PropertyKeyA key to be used for associating application-defined properties with streams within this connection.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(Http2Connection.Listener listener)Adds a listener of stream life-cycle events.voidclose(Promise<Void> promise)Close this connection.Http2StreamconnectionStream()Gets the stream object representing the connection, itself (i.e. stream zero).Http2StreamforEachActiveStream(Http2StreamVisitor visitor)Provide a means of iterating over the collection of active streams.booleangoAwayReceived()Indicates whether or not aGOAWAYwas received from the remote endpoint.voidgoAwayReceived(int lastKnownStream, long errorCode, Buffer message)Indicates that aGOAWAYwas received from the remote endpoint and sets the last known stream.booleangoAwaySent()Indicates whether or not aGOAWAYwas sent to the remote endpoint.booleangoAwaySent(int lastKnownStream, long errorCode, Buffer message)Updates the local state of thisHttp2Connectionas a result of aGOAWAYto send to the remote endpoint.booleanisServer()Indicates whether or not the local endpoint for this connection is the server.Http2Connection.Endpoint<Http2LocalFlowController>local()Gets a view of this connection from the localHttp2Connection.Endpoint.Http2Connection.PropertyKeynewKey()Creates a new key that is unique within thisHttp2Connection.intnumActiveStreams()Gets the number of streams that are actively in use (i.e.Http2Connection.Endpoint<Http2RemoteFlowController>remote()Gets a view of this connection from the remoteHttp2Connection.Endpoint.voidremoveListener(Http2Connection.Listener listener)Removes a listener of stream life-cycle events.Http2Streamstream(int streamId)Gets the stream if it exists.booleanstreamMayHaveExisted(int streamId)Indicates whether or not the given stream may have existed within this connection.
-
-
-
Method Detail
-
close
void close(Promise<Void> promise)
Close this connection. No more new streams can be created after this point and all streams that exists (active or otherwise) will be closed and removed.Note if iterating active streams via
forEachActiveStream(Http2StreamVisitor)and an exception is thrown it is necessary to call this method again to ensure the close completes.- Parameters:
promise- Will be completed when all streams have been removed, and listeners have been notified.
-
newKey
Http2Connection.PropertyKey newKey()
Creates a new key that is unique within thisHttp2Connection.
-
addListener
void addListener(Http2Connection.Listener listener)
Adds a listener of stream life-cycle events.
-
removeListener
void removeListener(Http2Connection.Listener listener)
Removes a listener of stream life-cycle events. If the same listener was added multiple times then only the first occurrence gets removed.
-
stream
Http2Stream stream(int streamId)
Gets the stream if it exists. If not, returnsnull.
-
streamMayHaveExisted
boolean streamMayHaveExisted(int streamId)
Indicates whether or not the given stream may have existed within this connection. This is a short form for callingHttp2Connection.Endpoint.mayHaveCreatedStream(int)on both endpoints.
-
connectionStream
Http2Stream connectionStream()
Gets the stream object representing the connection, itself (i.e. stream zero). This object always exists.
-
numActiveStreams
int numActiveStreams()
Gets the number of streams that are actively in use (i.e.OPENorHALF CLOSED).
-
forEachActiveStream
Http2Stream forEachActiveStream(Http2StreamVisitor visitor) throws Http2Exception
Provide a means of iterating over the collection of active streams.- Parameters:
visitor- The visitor which will visit each active stream.- Returns:
- The stream before iteration stopped or
nullif iteration went past the end. - Throws:
Http2Exception
-
isServer
boolean isServer()
Indicates whether or not the local endpoint for this connection is the server.
-
local
Http2Connection.Endpoint<Http2LocalFlowController> local()
Gets a view of this connection from the localHttp2Connection.Endpoint.
-
remote
Http2Connection.Endpoint<Http2RemoteFlowController> remote()
Gets a view of this connection from the remoteHttp2Connection.Endpoint.
-
goAwayReceived
boolean goAwayReceived()
Indicates whether or not aGOAWAYwas received from the remote endpoint.
-
goAwayReceived
void goAwayReceived(int lastKnownStream, long errorCode, Buffer message) throws Http2ExceptionIndicates that aGOAWAYwas received from the remote endpoint and sets the last known stream.- Parameters:
lastKnownStream- The Last-Stream-ID in the GOAWAY frame.errorCode- the Error Code in the GOAWAY frame.message- The Additional Debug Data in the GOAWAY frame. Note that reference count ownership belongs to the caller (ownership is not transferred to this method).- Throws:
Http2Exception
-
goAwaySent
boolean goAwaySent()
Indicates whether or not aGOAWAYwas sent to the remote endpoint.
-
goAwaySent
boolean goAwaySent(int lastKnownStream, long errorCode, Buffer message) throws Http2ExceptionUpdates the local state of thisHttp2Connectionas a result of aGOAWAYto send to the remote endpoint.- Parameters:
lastKnownStream- The Last-Stream-ID in the GOAWAY frame.errorCode- the Error Code in the GOAWAY frame. GOAWAY frame. Note that reference count ownership belongs to the caller (ownership is not transferred to this method).- Returns:
trueif the correspondingGOAWAYframe should be sent to the remote endpoint.- Throws:
Http2Exception
-
-