Class UndertowWebSocketClient
java.lang.Object
org.springframework.web.reactive.socket.client.UndertowWebSocketClient
- All Implemented Interfaces:
WebSocketClient
Undertow based implementation of
WebSocketClient
.- Since:
- 5.0
- Author:
- Violeta Georgieva, Rossen Stoyanchev
-
Constructor Summary
ConstructorDescriptionUndertowWebSocketClient
(org.xnio.XnioWorker worker) Constructor with theXnioWorker
to pass toWebSocketClient.connectionBuilder(org.xnio.XnioWorker, io.undertow.connector.ByteBufferPool, java.net.URI)
.UndertowWebSocketClient
(org.xnio.XnioWorker worker, io.undertow.connector.ByteBufferPool byteBufferPool, Consumer<io.undertow.websockets.client.WebSocketClient.ConnectionBuilder> builderConsumer) Alternate constructor providing additional control over theWebSocketClient.ConnectionBuilder
for each WebSocket connection.UndertowWebSocketClient
(org.xnio.XnioWorker worker, Consumer<io.undertow.websockets.client.WebSocketClient.ConnectionBuilder> builderConsumer) Alternate constructor providing additional control over theWebSocketClient.ConnectionBuilder
for each WebSocket connection. -
Method Summary
Modifier and TypeMethodDescriptionprotected io.undertow.websockets.client.WebSocketClient.ConnectionBuilder
Create aWebSocketClient.ConnectionBuilder
for the given URI.reactor.core.publisher.Mono<Void>
execute
(URI url, HttpHeaders headers, WebSocketHandler handler) A variant ofWebSocketClient.execute(URI, WebSocketHandler)
with custom headers.reactor.core.publisher.Mono<Void>
execute
(URI url, WebSocketHandler handler) Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.io.undertow.connector.ByteBufferPool
Return theByteBufferPool
currently used for newly created WebSocket sessions by this client.Consumer<io.undertow.websockets.client.WebSocketClient.ConnectionBuilder>
Return the configuredConsumer<ConnectionBuilder>
.org.xnio.XnioWorker
Return the configuredXnioWorker
.void
setByteBufferPool
(io.undertow.connector.ByteBufferPool byteBufferPool) Set theByteBufferPool
to pass toWebSocketClient.connectionBuilder(org.xnio.XnioWorker, io.undertow.connector.ByteBufferPool, java.net.URI)
.
-
Constructor Details
-
UndertowWebSocketClient
public UndertowWebSocketClient(org.xnio.XnioWorker worker) Constructor with theXnioWorker
to pass toWebSocketClient.connectionBuilder(org.xnio.XnioWorker, io.undertow.connector.ByteBufferPool, java.net.URI)
.- Parameters:
worker
- the Xnio worker
-
UndertowWebSocketClient
public UndertowWebSocketClient(org.xnio.XnioWorker worker, Consumer<io.undertow.websockets.client.WebSocketClient.ConnectionBuilder> builderConsumer) Alternate constructor providing additional control over theWebSocketClient.ConnectionBuilder
for each WebSocket connection.- Parameters:
worker
- the Xnio worker to use to createConnectionBuilder
'sbuilderConsumer
- a consumer to configureConnectionBuilder
's
-
UndertowWebSocketClient
public UndertowWebSocketClient(org.xnio.XnioWorker worker, io.undertow.connector.ByteBufferPool byteBufferPool, Consumer<io.undertow.websockets.client.WebSocketClient.ConnectionBuilder> builderConsumer) Alternate constructor providing additional control over theWebSocketClient.ConnectionBuilder
for each WebSocket connection.- Parameters:
worker
- the Xnio worker to use to createConnectionBuilder
'sbyteBufferPool
- the ByteBufferPool to use to createConnectionBuilder
'sbuilderConsumer
- a consumer to configureConnectionBuilder
's- Since:
- 5.0.8
-
-
Method Details
-
getXnioWorker
public org.xnio.XnioWorker getXnioWorker()Return the configuredXnioWorker
. -
setByteBufferPool
public void setByteBufferPool(io.undertow.connector.ByteBufferPool byteBufferPool) Set theByteBufferPool
to pass toWebSocketClient.connectionBuilder(org.xnio.XnioWorker, io.undertow.connector.ByteBufferPool, java.net.URI)
.By default an indirect
DefaultByteBufferPool
with a buffer size of 8192 is used.- Since:
- 5.0.8
- See Also:
-
DEFAULT_POOL_BUFFER_SIZE
-
getByteBufferPool
public io.undertow.connector.ByteBufferPool getByteBufferPool()Return theByteBufferPool
currently used for newly created WebSocket sessions by this client.- Returns:
- the byte buffer pool
- Since:
- 5.0.8
-
getConnectionBuilderConsumer
public Consumer<io.undertow.websockets.client.WebSocketClient.ConnectionBuilder> getConnectionBuilderConsumer()Return the configuredConsumer<ConnectionBuilder>
. -
execute
Description copied from interface:WebSocketClient
Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.- Specified by:
execute
in interfaceWebSocketClient
- Parameters:
url
- the handshake urlhandler
- the handler of the WebSocket session- Returns:
- completion
Mono<Void>
to indicate the outcome of the WebSocket session handling.
-
execute
public reactor.core.publisher.Mono<Void> execute(URI url, HttpHeaders headers, WebSocketHandler handler) Description copied from interface:WebSocketClient
A variant ofWebSocketClient.execute(URI, WebSocketHandler)
with custom headers.- Specified by:
execute
in interfaceWebSocketClient
- Parameters:
url
- the handshake urlheaders
- custom headers for the handshake requesthandler
- the handler of the WebSocket session- Returns:
- completion
Mono<Void>
to indicate the outcome of the WebSocket session handling.
-
createConnectionBuilder
protected io.undertow.websockets.client.WebSocketClient.ConnectionBuilder createConnectionBuilder(URI url) Create aWebSocketClient.ConnectionBuilder
for the given URI.The default implementation creates a builder with the configured
XnioWorker
andByteBufferPool
and then passes it to theconsumer
provided at construction time.
-