Top Description Inners Fields Constructors Methods
org.springframework.web.reactive.socket.client

public Class UndertowWebSocketClient

extends Object
implements WebSocketClient
Class Inheritance
All Implemented Interfaces
org.springframework.web.reactive.socket.client.WebSocketClient
Imports
java.io.IOException, java.net.URI, java.util.Collections, .List, .Map, java.util.function.Consumer, io.undertow.connector.ByteBufferPool, io.undertow.server.DefaultByteBufferPool, io.undertow.websockets.client.WebSocketClient.ConnectionBuilder, .WebSocketClientNegotiation, io.undertow.websockets.core.WebSocketChannel, org.apache.commons.logging.Log, .LogFactory, org.xnio.IoFuture, .XnioWorker, reactor.core.publisher.Mono, .Sinks, org.springframework.core.io.buffer.DataBufferFactory, .DefaultDataBufferFactory, org.springframework.http.HttpHeaders, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.reactive.socket.HandshakeInfo, .WebSocketHandler, org.springframework.web.reactive.socket.adapter.ContextWebSocketHandler, .UndertowWebSocketHandlerAdapter, .UndertowWebSocketSession

Undertow based implementation of WebSocketClient.
Authors
Violeta Georgieva, Rossen Stoyanchev
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final Consumer<WebSocketClient.ConnectionBuilder>
private ByteBufferPool
private static final int
private static final Log
private final XnioWorker

Constructor Summary

AccessConstructor and Description
public
public
UndertowWebSocketClient(XnioWorker
the Xnio worker to use to create ConnectionBuilder's
worker
,
Consumer<WebSocketClient.ConnectionBuilder>
a consumer to configure ConnectionBuilder's
builderConsumer
)

Alternate constructor providing additional control over the ConnectionBuilder for each WebSocket connection.

public
UndertowWebSocketClient(XnioWorker
the Xnio worker to use to create ConnectionBuilder's
worker
,
ByteBufferPool
the ByteBufferPool to use to create ConnectionBuilder's
byteBufferPool
,
Consumer<WebSocketClient.ConnectionBuilder>
a consumer to configure ConnectionBuilder's
builderConsumer
)

Alternate constructor providing additional control over the ConnectionBuilder for each WebSocket connection.

Method Summary

Modifier and TypeMethod and Description
protected WebSocketClient.ConnectionBuilder
createConnectionBuilder(URI url)

Create a ConnectionBuilder for the given URI.

private HandshakeInfo
public Mono<Void>
execute(URI
the handshake url
url
,
WebSocketHandler
the handler of the WebSocket session
handler
)

Implements org.springframework.web.reactive.socket.client.WebSocketClient.execute.

Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.

public Mono<Void>
execute(URI
the handshake url
url
,
HttpHeaders
custom headers for the handshake request
headers
,
WebSocketHandler
the handler of the WebSocket session
handler
)

Implements org.springframework.web.reactive.socket.client.WebSocketClient.execute.

A variant of execute(URI, WebSocketHandler) with custom headers.

private Mono<Void>
public ByteBufferPool

Returns:

the byte buffer pool
getByteBufferPool
()

Return the io.undertow.connector.ByteBufferPool currently used for newly created WebSocket sessions by this client.

public Consumer<WebSocketClient.ConnectionBuilder>
getConnectionBuilderConsumer()

Return the configured Consumer<ConnectionBuilder>.

public XnioWorker
getXnioWorker()

Return the configured XnioWorker.

private void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

builderConsumerback to summary
private final Consumer<WebSocketClient.ConnectionBuilder> builderConsumer
byteBufferPoolback to summary
private ByteBufferPool byteBufferPool
DEFAULT_POOL_BUFFER_SIZEback to summary
private static final int DEFAULT_POOL_BUFFER_SIZE
loggerback to summary
private static final Log logger
workerback to summary
private final XnioWorker worker

Constructor Detail

UndertowWebSocketClientback to summary
public UndertowWebSocketClient(XnioWorker worker)

Constructor with the XnioWorker to pass to io.undertow.websockets.client.WebSocketClient#connectionBuilder.

Parameters
worker:XnioWorker

the Xnio worker

UndertowWebSocketClientback to summary
public UndertowWebSocketClient(XnioWorker worker, Consumer<WebSocketClient.ConnectionBuilder> builderConsumer)

Alternate constructor providing additional control over the ConnectionBuilder for each WebSocket connection.

Parameters
worker:XnioWorker

the Xnio worker to use to create ConnectionBuilder's

builderConsumer:Consumer<WebSocketClient.ConnectionBuilder>

a consumer to configure ConnectionBuilder's

UndertowWebSocketClientback to summary
public UndertowWebSocketClient(XnioWorker worker, ByteBufferPool byteBufferPool, Consumer<WebSocketClient.ConnectionBuilder> builderConsumer)

Alternate constructor providing additional control over the ConnectionBuilder for each WebSocket connection.

Parameters
worker:XnioWorker

the Xnio worker to use to create ConnectionBuilder's

byteBufferPool:ByteBufferPool

the ByteBufferPool to use to create ConnectionBuilder's

builderConsumer:Consumer<WebSocketClient.ConnectionBuilder>

a consumer to configure ConnectionBuilder's

Since
5.0.8

Method Detail

createConnectionBuilderback to summary
protected WebSocketClient.ConnectionBuilder createConnectionBuilder(URI url)

Create a 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.

createHandshakeInfoback to summary
private HandshakeInfo createHandshakeInfo(URI url, UndertowWebSocketClient.DefaultNegotiation negotiation)
executeback to summary
public Mono<Void> execute(URI url, WebSocketHandler handler)

Implements org.springframework.web.reactive.socket.client.WebSocketClient.execute.

Doc from org.springframework.web.reactive.socket.client.WebSocketClient.execute.

Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.

Parameters
url:URI

the handshake url

handler:WebSocketHandler

the handler of the WebSocket session

Returns:Mono<Void>

completion Mono<Void> to indicate the outcome of the WebSocket session handling.

Annotations
@Override
executeback to summary
public Mono<Void> execute(URI url, HttpHeaders headers, WebSocketHandler handler)

Implements org.springframework.web.reactive.socket.client.WebSocketClient.execute.

Doc from org.springframework.web.reactive.socket.client.WebSocketClient.execute.

A variant of execute(URI, WebSocketHandler) with custom headers.

Parameters
url:URI

the handshake url

headers:HttpHeaders

custom headers for the handshake request

handler:WebSocketHandler

the handler of the WebSocket session

Returns:Mono<Void>

completion Mono<Void> to indicate the outcome of the WebSocket session handling.

Annotations
@Override
executeInternalback to summary
private Mono<Void> executeInternal(URI url, HttpHeaders headers, WebSocketHandler handler)
getByteBufferPoolback to summary
public ByteBufferPool getByteBufferPool()

Return the io.undertow.connector.ByteBufferPool currently used for newly created WebSocket sessions by this client.

Returns:ByteBufferPool

the byte buffer pool

Since
5.0.8
getConnectionBuilderConsumerback to summary
public Consumer<WebSocketClient.ConnectionBuilder> getConnectionBuilderConsumer()

Return the configured Consumer<ConnectionBuilder>.

getXnioWorkerback to summary
public XnioWorker getXnioWorker()

Return the configured XnioWorker.

handleChannelback to summary
private void handleChannel(URI url, WebSocketHandler handler, Sinks.Empty<Void> completionSink, UndertowWebSocketClient.DefaultNegotiation negotiation, WebSocketChannel channel)
setByteBufferPoolback to summary
public void setByteBufferPool(ByteBufferPool byteBufferPool)

Set the 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.

Since
5.0.8
See Also
DEFAULT_POOL_BUFFER_SIZE
org.springframework.web.reactive.socket.client back to summary

private final Class UndertowWebSocketClient.DefaultNegotiation

extends WebSocketClientNegotiation
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final WebSocketClientNegotiation
private final HttpHeaders
private final HttpHeaders

Constructor Summary

AccessConstructor and Description
public
DefaultNegotiation(List<String> protocols, HttpHeaders requestHeaders, WebSocketClient.ConnectionBuilder connectionBuilder)

Method Summary

Modifier and TypeMethod and Description
public void
public void
public HttpHeaders
Inherited from io.undertow.websockets.client.WebSocketClientNegotiation:
getSelectedExtensionsgetSelectedSubProtocolgetSupportedExtensionsgetSupportedSubProtocolshandshakeComplete

Field Detail

delegateback to summary
private final WebSocketClientNegotiation delegate
Annotations
@Nullable
requestHeadersback to summary
private final HttpHeaders requestHeaders
responseHeadersback to summary
private final HttpHeaders responseHeaders

Constructor Detail

DefaultNegotiationback to summary
public DefaultNegotiation(List<String> protocols, HttpHeaders requestHeaders, WebSocketClient.ConnectionBuilder connectionBuilder)

Method Detail

afterRequestback to summary
public void afterRequest(Map<String, List<String>> headers)

Overrides io.undertow.websockets.client.WebSocketClientNegotiation.afterRequest.

Annotations
@Override
beforeRequestback to summary
public void beforeRequest(Map<String, List<String>> headers)

Overrides io.undertow.websockets.client.WebSocketClientNegotiation.beforeRequest.

Annotations
@Override
getResponseHeadersback to summary
public HttpHeaders getResponseHeaders()