Interface Http2Connection
- All Known Implementing Classes:
DefaultHttp2Connection
public interface Http2Connection
Manager for the state of an HTTP/2 connection with the remote end-point.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceHttp2Connection.Endpoint<F extends Http2FlowController>A view of the connection from one endpoint (local or remote).static interfaceListener for life-cycle events for streams in this connection.static interfaceA key to be used for associating application-defined properties with streams within this connection. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(Http2Connection.Listener listener) Adds a listener of stream life-cycle events.Close this connection.Gets the stream object representing the connection, itself (i.e. stream zero).forEachActiveStream(Http2StreamVisitor visitor) Provide a means of iterating over the collection of active streams.booleanIndicates whether or not aGOAWAYwas received from the remote endpoint.voidgoAwayReceived(int lastKnownStream, long errorCode, ByteBuf message) Indicates that aGOAWAYwas received from the remote endpoint and sets the last known stream.booleanIndicates whether or not aGOAWAYwas sent to the remote endpoint.booleangoAwaySent(int lastKnownStream, long errorCode, ByteBuf 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.local()Gets a view of this connection from the localHttp2Connection.Endpoint.newKey()Creates a new key that is unique within thisHttp2Connection.intGets the number of streams that are actively in use (i.e.remote()Gets a view of this connection from the remoteHttp2Connection.Endpoint.voidremoveListener(Http2Connection.Listener listener) Removes a listener of stream life-cycle events.stream(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 Details
-
close
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.- Returns:
- A future that 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
Adds a listener of stream life-cycle events. -
removeListener
Removes a listener of stream life-cycle events. If the same listener was added multiple times then only the first occurrence gets removed. -
stream
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
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
Gets a view of this connection from the localHttp2Connection.Endpoint. -
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
Indicates 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
Updates 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
-