public class StandardWebSocketClient extends AbstractWebSocketClient
Modifier and Type | Class and Description |
---|---|
private class |
StandardWebSocketClient.StandardWebSocketClientConfigurator |
Modifier and Type | Field and Description |
---|---|
private AsyncListenableTaskExecutor |
taskExecutor |
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 |
---|---|
private static java.util.List<Extension> |
adaptExtensions(java.util.List<WebSocketExtension> extensions) |
protected ListenableFuture<WebSocketSession> |
doHandshakeInternal(WebSocketHandler webSocketHandler,
HttpHeaders headers,
java.net.URI uri,
java.util.List<java.lang.String> protocols,
java.util.List<WebSocketExtension> extensions,
java.util.Map<java.lang.String,java.lang.Object> attributes)
Perform the actual handshake to establish a connection to the server.
|
private java.net.InetAddress |
getLocalHost() |
private int |
getPort(java.net.URI uri) |
AsyncListenableTaskExecutor |
getTaskExecutor()
Return the configured
TaskExecutor . |
void |
setTaskExecutor(AsyncListenableTaskExecutor taskExecutor)
Set an
AsyncListenableTaskExecutor to use when opening connections. |
doHandshake, doHandshake
private final WebSocketContainer webSocketContainer
private AsyncListenableTaskExecutor taskExecutor
public StandardWebSocketClient()
ContainerProvider.getWebSocketContainer()
to obtain a (new) WebSocketContainer
instance. Also see constructor
accepting existing WebSocketContainer
instance.public StandardWebSocketClient(WebSocketContainer webSocketContainer)
WebSocketContainer
instance.
For XML configuration see WebSocketContainerFactoryBean
. For Java
configuration use ContainerProvider.getWebSocketContainer()
to obtain
the WebSocketContainer
instance.
public void setTaskExecutor(AsyncListenableTaskExecutor taskExecutor)
AsyncListenableTaskExecutor
to use when opening connections.
If this property is not configured, calls to any of the
doHandshake
methods will block until the connection is established.
public AsyncListenableTaskExecutor getTaskExecutor()
TaskExecutor
.protected ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler webSocketHandler, HttpHeaders headers, java.net.URI uri, java.util.List<java.lang.String> protocols, java.util.List<WebSocketExtension> extensions, java.util.Map<java.lang.String,java.lang.Object> attributes)
AbstractWebSocketClient
doHandshakeInternal
in class AbstractWebSocketClient
webSocketHandler
- the client-side handler for WebSocket messagesheaders
- HTTP headers to use for the handshake, with unwanted (forbidden)
headers filtered out, never null
uri
- the target URI for the handshake, never null
protocols
- requested sub-protocols, or an empty listextensions
- requested WebSocket extensions, or an empty listattributes
- attributes to associate with the WebSocketSession, i.e. via
WebSocketSession.getAttributes()
; currently always an empty map.private static java.util.List<Extension> adaptExtensions(java.util.List<WebSocketExtension> extensions)
private java.net.InetAddress getLocalHost()
private int getPort(java.net.URI uri)