Interface ClientConnection

  • All Superinterfaces:
    java.lang.AutoCloseable, java.nio.channels.Channel, java.io.Closeable
    All Known Implementing Classes:
    Http2ClientConnection

    public interface ClientConnection
    extends java.nio.channels.Channel
    A client connection. This can be used to send requests, or to upgrade the connection.

    In general these objects are not thread safe, they should only be used by the IO thread that is responsible for the connection. As a result this client does not provide a mechanism to perform blocking IO, it is designed for async operation only.

    Author:
    Stuart Douglas
    • Method Detail

      • sendRequest

        void sendRequest​(ClientRequest request,
                         ClientCallback<ClientExchange> clientCallback)
        Sends a client request. The request object should not be modified after it has been submitted to the connection.

        Request objects can be queued. Once the request is in a state that it is ready to be sent the clientCallback is invoked to provide the caller with the ClientExchange

        If isMultiplexingSupported() returns true then multiple requests may be active at the same time, and a later request may complete before an earlier one.

        Note that the request header may not be written out until after the callback has been invoked. This allows the client to write out a header with a gathering write if the request contains content.

        Parameters:
        request - The request to send.
      • performUpgrade

        org.xnio.StreamConnection performUpgrade()
                                          throws java.io.IOException
        Upgrade the connection, if the underlying protocol supports it. This should only be called after an upgrade request has been submitted and the target server has accepted the upgrade.
        Returns:
        The resulting StreamConnection
        Throws:
        java.io.IOException
      • getBufferPool

        ByteBufferPool getBufferPool()
        Returns:
        The buffer pool used by the client
      • getPeerAddress

        java.net.SocketAddress getPeerAddress()
      • getPeerAddress

        <A extends java.net.SocketAddress> A getPeerAddress​(java.lang.Class<A> type)
      • getCloseSetter

        org.xnio.ChannelListener.Setter<? extends ClientConnection> getCloseSetter()
      • getLocalAddress

        java.net.SocketAddress getLocalAddress()
      • getLocalAddress

        <A extends java.net.SocketAddress> A getLocalAddress​(java.lang.Class<A> type)
      • getWorker

        org.xnio.XnioWorker getWorker()
      • getIoThread

        org.xnio.XnioIoThread getIoThread()
      • isOpen

        boolean isOpen()
        Specified by:
        isOpen in interface java.nio.channels.Channel
      • supportsOption

        boolean supportsOption​(org.xnio.Option<?> option)
      • getOption

        <T> T getOption​(org.xnio.Option<T> option)
                 throws java.io.IOException
        Throws:
        java.io.IOException
      • setOption

        <T> T setOption​(org.xnio.Option<T> option,
                        T value)
                 throws java.lang.IllegalArgumentException,
                        java.io.IOException
        Throws:
        java.lang.IllegalArgumentException
        java.io.IOException
      • isUpgraded

        boolean isUpgraded()
      • isPushSupported

        boolean isPushSupported()
        Returns:
        true if this connection support server push
      • isMultiplexingSupported

        boolean isMultiplexingSupported()
        Returns:
        true if this client supports multiplexing
      • getStatistics

        ClientStatistics getStatistics()
        Returns:
        the statistics information, or null if statistics are not supported or disabled
      • isUpgradeSupported

        boolean isUpgradeSupported()
      • addCloseListener

        void addCloseListener​(org.xnio.ChannelListener<ClientConnection> listener)
        Adds a close listener, than will be invoked with the connection is closed
        Parameters:
        listener - The close listener
      • isPingSupported

        default boolean isPingSupported()
        Returns:
        true if the underlying protocol supports sending a ping