public class UndertowWebSocketClient extends WebSocketClientSupport implements WebSocketClient
WebSocketClient
.Modifier and Type | Class and Description |
---|---|
private static class |
UndertowWebSocketClient.DefaultNegotiation |
Modifier and Type | Field and Description |
---|---|
private DataBufferFactory |
bufferFactory |
private java.util.function.Consumer<ConnectionBuilder> |
builderConsumer |
private ByteBufferPool |
byteBufferPool |
private static int |
DEFAULT_POOL_BUFFER_SIZE |
private XnioWorker |
worker |
logger
Constructor and Description |
---|
UndertowWebSocketClient(XnioWorker worker)
Constructor with the
XnioWorker to pass to
io.undertow.websockets.client.WebSocketClient#connectionBuilder |
UndertowWebSocketClient(XnioWorker worker,
ByteBufferPool byteBufferPool,
java.util.function.Consumer<ConnectionBuilder> builderConsumer)
Alternate constructor providing additional control over the
ConnectionBuilder for each WebSocket connection. |
UndertowWebSocketClient(XnioWorker worker,
java.util.function.Consumer<ConnectionBuilder> builderConsumer)
Alternate constructor providing additional control over the
ConnectionBuilder for each WebSocket connection. |
Modifier and Type | Method and Description |
---|---|
protected ConnectionBuilder |
createConnectionBuilder(java.net.URI url)
Create a
ConnectionBuilder for the given URI. |
<any> |
execute(java.net.URI url,
HttpHeaders headers,
WebSocketHandler handler)
A variant of
WebSocketClient.execute(URI, WebSocketHandler) with custom headers. |
<any> |
execute(java.net.URI url,
WebSocketHandler handler)
Execute a handshake request to the given url and handle the resulting
WebSocket session with the given handler.
|
private <any> |
executeInternal(java.net.URI url,
HttpHeaders headers,
WebSocketHandler handler) |
ByteBufferPool |
getByteBufferPool() |
java.util.function.Consumer<ConnectionBuilder> |
getConnectionBuilderConsumer()
Return the configured
Consumer<ConnectionBuilder . |
int |
getPoolBufferSize()
Deprecated.
as of 5.0.8 this method is deprecated in favor
of using
getByteBufferPool() |
XnioWorker |
getXnioWorker()
Return the configured
XnioWorker . |
private void |
handleChannel(java.net.URI url,
WebSocketHandler handler,
<any> completion,
UndertowWebSocketClient.DefaultNegotiation negotiation,
WebSocketChannel channel) |
void |
setByteBufferPool(ByteBufferPool byteBufferPool)
Set the
ByteBufferPool to pass to
io.undertow.websockets.client.WebSocketClient#connectionBuilder . |
void |
setPoolBufferSize(int poolBufferSize)
Deprecated.
as of 5.0.8 this method is deprecated in favor
of
#setByteBufferPool(io.undertow.connector.ByteBufferPool) |
afterHandshake, beforeHandshake
private static final int DEFAULT_POOL_BUFFER_SIZE
private final XnioWorker worker
private ByteBufferPool byteBufferPool
private final java.util.function.Consumer<ConnectionBuilder> builderConsumer
private final DataBufferFactory bufferFactory
public UndertowWebSocketClient(XnioWorker worker)
XnioWorker
to pass to
io.undertow.websockets.client.WebSocketClient#connectionBuilder
worker
- the Xnio workerpublic UndertowWebSocketClient(XnioWorker worker, java.util.function.Consumer<ConnectionBuilder> builderConsumer)
ConnectionBuilder
for each WebSocket connection.worker
- the Xnio worker to use to create ConnectionBuilder
'sbuilderConsumer
- a consumer to configure ConnectionBuilder
'spublic UndertowWebSocketClient(XnioWorker worker, ByteBufferPool byteBufferPool, java.util.function.Consumer<ConnectionBuilder> builderConsumer)
ConnectionBuilder
for each WebSocket connection.worker
- the Xnio worker to use to create ConnectionBuilder
'sbyteBufferPool
- the ByteBufferPool to use to create ConnectionBuilder
'sbuilderConsumer
- a consumer to configure ConnectionBuilder
'spublic XnioWorker getXnioWorker()
XnioWorker
.public void setByteBufferPool(ByteBufferPool byteBufferPool)
ByteBufferPool
to pass to
io.undertow.websockets.client.WebSocketClient#connectionBuilder
.
By default an indirect io.undertow.server.DefaultByteBufferPool
with a buffer size
of 8192 is used.
public ByteBufferPool getByteBufferPool()
io.undertow.connector.ByteBufferPool
currently used
for newly created WebSocket sessions by this clientpublic java.util.function.Consumer<ConnectionBuilder> getConnectionBuilderConsumer()
Consumer<ConnectionBuilder
.@Deprecated public void setPoolBufferSize(int poolBufferSize)
#setByteBufferPool(io.undertow.connector.ByteBufferPool)
ByteBufferPool
to pass to
io.undertow.websockets.client.WebSocketClient#connectionBuilder
.
By default the buffer size is set to 8192.
@Deprecated public int getPoolBufferSize()
getByteBufferPool()
ByteBufferPool
.public <any> execute(java.net.URI url, WebSocketHandler handler)
WebSocketClient
execute
in interface WebSocketClient
url
- the handshake urlhandler
- the handler of the WebSocket sessionMono<Void>
to indicate the outcome of the
WebSocket session handling.public <any> execute(java.net.URI url, HttpHeaders headers, WebSocketHandler handler)
WebSocketClient
WebSocketClient.execute(URI, WebSocketHandler)
with custom headers.execute
in interface WebSocketClient
url
- the handshake urlheaders
- custom headers for the handshake requesthandler
- the handler of the WebSocket sessionMono<Void>
to indicate the outcome of the
WebSocket session handling.private <any> executeInternal(java.net.URI url, HttpHeaders headers, WebSocketHandler handler)
protected ConnectionBuilder createConnectionBuilder(java.net.URI url)
ConnectionBuilder
for the given URI.
The default implementation creates a builder with the configured
XnioWorker
and ByteBufferPool
and
then passes it to the consumer
provided at construction time.
private void handleChannel(java.net.URI url, WebSocketHandler handler, <any> completion, UndertowWebSocketClient.DefaultNegotiation negotiation, WebSocketChannel channel)