-
- 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 interface
Http2Connection.Endpoint<F extends Http2FlowController>
A view of the connection from one endpoint (local or remote).static interface
Http2Connection.Listener
Listener for life-cycle events for streams in this connection.static interface
Http2Connection.PropertyKey
A 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 void
addListener(Http2Connection.Listener listener)
Adds a listener of stream life-cycle events.void
close(Promise<Void> promise)
Close this connection.Http2Stream
connectionStream()
Gets the stream object representing the connection, itself (i.e. stream zero).Http2Stream
forEachActiveStream(Http2StreamVisitor visitor)
Provide a means of iterating over the collection of active streams.boolean
goAwayReceived()
Indicates whether or not aGOAWAY
was received from the remote endpoint.void
goAwayReceived(int lastKnownStream, long errorCode, Buffer message)
Indicates that aGOAWAY
was received from the remote endpoint and sets the last known stream.boolean
goAwaySent()
Indicates whether or not aGOAWAY
was sent to the remote endpoint.boolean
goAwaySent(int lastKnownStream, long errorCode, Buffer message)
Updates the local state of thisHttp2Connection
as a result of aGOAWAY
to send to the remote endpoint.boolean
isServer()
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.PropertyKey
newKey()
Creates a new key that is unique within thisHttp2Connection
.int
numActiveStreams()
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
.void
removeListener(Http2Connection.Listener listener)
Removes a listener of stream life-cycle events.Http2Stream
stream(int streamId)
Gets the stream if it exists.boolean
streamMayHaveExisted(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.OPEN
orHALF 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
null
if 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 aGOAWAY
was received from the remote endpoint.
-
goAwayReceived
void goAwayReceived(int lastKnownStream, long errorCode, Buffer message) throws Http2Exception
Indicates that aGOAWAY
was 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 aGOAWAY
was sent to the remote endpoint.
-
goAwaySent
boolean goAwaySent(int lastKnownStream, long errorCode, Buffer message) throws Http2Exception
Updates the local state of thisHttp2Connection
as a result of aGOAWAY
to 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:
true
if the correspondingGOAWAY
frame should be sent to the remote endpoint.- Throws:
Http2Exception
-
-