public class StandardWebSocketClient extends WebSocketClientSupport implements WebSocketClient
WebSocketClient
implementation for use with the Java WebSocket API.Modifier and Type | Class and Description |
---|---|
private static class |
StandardWebSocketClient.DefaultConfigurator |
Modifier and Type | Field and Description |
---|---|
private DataBufferFactory |
bufferFactory |
private WebSocketContainer |
webSocketContainer |
logger
Constructor and Description |
---|
StandardWebSocketClient()
Default constructor that calls
ContainerProvider.getWebSocketContainer() to obtain a (new)
WebSocketContainer instance. |
StandardWebSocketClient(WebSocketContainer webSocketContainer)
Constructor accepting an existing
WebSocketContainer instance. |
Modifier and Type | Method and Description |
---|---|
protected DataBufferFactory |
bufferFactory() |
private StandardWebSocketHandlerAdapter |
createEndpoint(java.net.URI url,
WebSocketHandler handler,
<any> completion,
StandardWebSocketClient.DefaultConfigurator configurator) |
private ClientEndpointConfig |
createEndpointConfig(Configurator configurator,
java.util.List<java.lang.String> subProtocols) |
protected StandardWebSocketSession |
createWebSocketSession(Session session,
HandshakeInfo info,
<any> completion) |
<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 requestHeaders,
WebSocketHandler handler) |
WebSocketContainer |
getWebSocketContainer()
Return the configured
WebSocketContainer to use. |
afterHandshake, beforeHandshake
private final DataBufferFactory bufferFactory
private final WebSocketContainer webSocketContainer
public StandardWebSocketClient()
ContainerProvider.getWebSocketContainer()
to obtain a (new)
WebSocketContainer
instance.public StandardWebSocketClient(WebSocketContainer webSocketContainer)
WebSocketContainer
instance.webSocketContainer
- a web socket containerpublic WebSocketContainer getWebSocketContainer()
WebSocketContainer
to use.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 requestHeaders, WebSocketHandler handler)
private StandardWebSocketHandlerAdapter createEndpoint(java.net.URI url, WebSocketHandler handler, <any> completion, StandardWebSocketClient.DefaultConfigurator configurator)
protected StandardWebSocketSession createWebSocketSession(Session session, HandshakeInfo info, <any> completion)
private ClientEndpointConfig createEndpointConfig(Configurator configurator, java.util.List<java.lang.String> subProtocols)
protected DataBufferFactory bufferFactory()