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 TypeMethodDescriptionvoidaddCloseListener(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> TgetOption(org.xnio.Option<T> option) <A extends SocketAddress>
AgetPeerAddress(Class<A> type) org.xnio.XnioWorkerbooleanbooleanisOpen()default booleanbooleanbooleanbooleanorg.xnio.StreamConnectionUpgrade 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 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
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
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:
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
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
-