io.undertow.client

## Interface ClientConnection

All Superinterfaces:
  AutoCloseable, Channel, Closeable

All Known Implementing Classes:
  Http2ClientConnection

    public interface ClientConnection
    extends 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

### Nested Class Summary

Nested Classes
`static interface` `ClientConnection.PingListener`

### Method Summary

All Methods Instance Methods Abstract Methods Default Methods
`void` `addCloseListener(org.xnio.ChannelListener<ClientConnection> listener)` Adds a close listener, than will be invoked with the connection is closed
`ByteBufferPool` `getBufferPool()`
`org.xnio.ChannelListener.Setter<? extends ClientConnection>` `getCloseSetter()`
`org.xnio.XnioIoThread` `getIoThread()`
`SocketAddress` `getLocalAddress()`
`<A extends SocketAddress> A` `getLocalAddress(Class<A> type)`
`<T> T` `getOption(org.xnio.Option<T> option)`
`SocketAddress` `getPeerAddress()`
`<A extends SocketAddress> A` `getPeerAddress(Class<A> type)`
`ClientStatistics` `getStatistics()`
`org.xnio.XnioWorker` `getWorker()`
`boolean` `isMultiplexingSupported()`
`boolean` `isOpen()`
`default boolean` `isPingSupported()`
`boolean` `isPushSupported()`
`boolean` `isUpgraded()`
`boolean` `isUpgradeSupported()`
`org.xnio.StreamConnection` `performUpgrade()` Upgrade the connection, if the underlying protocol supports it.
`default void` `sendPing(ClientConnection.PingListener listener, long timeout, TimeUnit timeUnit)`
`void` `sendRequest(ClientRequest request, ClientCallback<ClientExchange> clientCallback)` Sends a client request.
`<T> T` `setOption(org.xnio.Option<T> option, T value)`
`boolean` `supportsOption(org.xnio.Option<?> option)`

### Methods inherited from interface java.nio.channels.Channel

`close`

### 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 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:
  `IOException`

#### getBufferPool

    ByteBufferPool getBufferPool()

Returns:
  The buffer pool used by the client

#### getPeerAddress

    SocketAddress getPeerAddress()

#### getPeerAddress

    <A extends SocketAddress> A getPeerAddress(Class<A> type)

#### getCloseSetter

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

#### getLocalAddress

    SocketAddress getLocalAddress()

#### getLocalAddress

    <A extends SocketAddress> A getLocalAddress(Class<A> type)

#### getWorker

    org.xnio.XnioWorker getWorker()

#### getIoThread

    org.xnio.XnioIoThread getIoThread()

#### isOpen

    boolean isOpen()

Specified by:
  `isOpen` in interface `Channel`

#### supportsOption

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

#### getOption

    <T> T getOption(org.xnio.Option<T> option)
             throws IOException

Throws:
  `IOException`

#### setOption

    <T> T setOption(org.xnio.Option<T> option,
                    T value)
             throws IllegalArgumentException,
                    IOException

Throws:
  `IllegalArgumentException`
  `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

#### sendPing

    default void sendPing(ClientConnection.PingListener listener,
                          long timeout,
                          TimeUnit timeUnit)