Interface ClientConnection
- All Superinterfaces:
AutoCloseable
,Channel
,Closeable
- All Known Implementing Classes:
Http2ClientConnection
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCloseListener
(org.xnio.ChannelListener<ClientConnection> listener) Adds a close listener, than will be invoked with the connection is closedorg.xnio.ChannelListener.Setter<? extends ClientConnection>
org.xnio.XnioIoThread
<A extends SocketAddress>
AgetLocalAddress
(Class<A> type) <T> T
getOption
(org.xnio.Option<T> option) <A extends SocketAddress>
AgetPeerAddress
(Class<A> type) org.xnio.XnioWorker
boolean
boolean
isOpen()
default boolean
boolean
boolean
boolean
org.xnio.StreamConnection
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)
-
Method Details
-
sendRequest
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 theClientExchange
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
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
-
getCloseSetter
org.xnio.ChannelListener.Setter<? extends ClientConnection> getCloseSetter() -
getLocalAddress
SocketAddress getLocalAddress() -
getLocalAddress
-
getWorker
org.xnio.XnioWorker getWorker() -
getIoThread
org.xnio.XnioIoThread getIoThread() -
isOpen
boolean isOpen() -
supportsOption
boolean supportsOption(org.xnio.Option<?> option) -
getOption
- Throws:
IOException
-
setOption
- 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
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
-