Interface Http2Connection

  • All Known Implementing Classes:
    DefaultHttp2Connection

    @UnstableApi
    public interface Http2Connection
    Manager for the state of an HTTP/2 connection with the remote end-point.
    • 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.
      • 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, returns null.
      • streamMayHaveExisted

        boolean streamMayHaveExisted​(int streamId)
        Indicates whether or not the given stream may have existed within this connection. This is a short form for calling Http2Connection.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 or HALF 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.
      • goAwayReceived

        boolean goAwayReceived()
        Indicates whether or not a GOAWAY was received from the remote endpoint.
      • goAwayReceived

        void goAwayReceived​(int lastKnownStream,
                            long errorCode,
                            Buffer message)
                     throws Http2Exception
        Indicates that a GOAWAY 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 a GOAWAY was sent to the remote endpoint.
      • goAwaySent

        boolean goAwaySent​(int lastKnownStream,
                           long errorCode,
                           Buffer message)
                    throws Http2Exception
        Updates the local state of this Http2Connection as a result of a GOAWAY 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 corresponding GOAWAY frame should be sent to the remote endpoint.
        Throws:
        Http2Exception