public class StandardWebSocketClient extends AbstractWebSocketClient
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 ListenableFuture<WebSocketSession> |
doHandshakeInternal(WebSocketHandler webSocketHandler,
HttpHeaders headers,
URI uri,
List<String> protocols,
List<WebSocketExtension> extensions,
Map<String,Object> attributes)
Perform the actual handshake to establish a connection to the server.
|
AsyncListenableTaskExecutor |
getTaskExecutor()
Return the configured
TaskExecutor . |
void |
setTaskExecutor(AsyncListenableTaskExecutor taskExecutor)
Set an
AsyncListenableTaskExecutor to use when opening connections. |
doHandshake, doHandshake
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 set to null
, calls to any of the
doHandshake
methods will block until the connection is established.
By default, an instance of SimpleAsyncTaskExecutor
is used.
public AsyncListenableTaskExecutor getTaskExecutor()
TaskExecutor
.protected ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler webSocketHandler, HttpHeaders headers, URI uri, List<String> protocols, List<WebSocketExtension> extensions, Map<String,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.