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 Modifier and Type Interface Description static interfaceClientConnection.PingListener
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddCloseListener(org.xnio.ChannelListener<ClientConnection> listener)Adds a close listener, than will be invoked with the connection is closedByteBufferPoolgetBufferPool()org.xnio.ChannelListener.Setter<? extends ClientConnection>getCloseSetter()org.xnio.XnioIoThreadgetIoThread()SocketAddressgetLocalAddress()<A extends SocketAddress>
AgetLocalAddress(Class<A> type)<T> TgetOption(org.xnio.Option<T> option)SocketAddressgetPeerAddress()<A extends SocketAddress>
AgetPeerAddress(Class<A> type)ClientStatisticsgetStatistics()org.xnio.XnioWorkergetWorker()booleanisMultiplexingSupported()booleanisOpen()default booleanisPingSupported()booleanisPushSupported()booleanisUpgraded()booleanisUpgradeSupported()org.xnio.StreamConnectionperformUpgrade()Upgrade the connection, if the underlying protocol supports it.default voidsendPing(ClientConnection.PingListener listener, long timeout, TimeUnit timeUnit)voidsendRequest(ClientRequest request, ClientCallback<ClientExchange> clientCallback)Sends a client request.<T> TsetOption(org.xnio.Option<T> option, T value)booleansupportsOption(org.xnio.Option<?> option)
-
-
-
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
clientCallbackis invoked to provide the caller with theClientExchangeIf
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 IOExceptionUpgrade 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()
-
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:
IllegalArgumentExceptionIOException
-
isUpgraded
boolean isUpgraded()
-
isPushSupported
boolean isPushSupported()
- Returns:
trueif this connection support server push
-
isMultiplexingSupported
boolean isMultiplexingSupported()
- Returns:
trueif this client supports multiplexing
-
getStatistics
ClientStatistics getStatistics()
- Returns:
- the statistics information, or
nullif 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:
trueif the underlying protocol supports sending a ping
-
sendPing
default void sendPing(ClientConnection.PingListener listener, long timeout, TimeUnit timeUnit)
-
-