public class StandardWebSocketClient extends AbstractWebSocketClient
logger
Constructor and Description |
---|
StandardWebSocketClient()
Default constructor that calls
ContainerProvider.getWebSocketContainer()
to obtain a (new) WebSocketContainer instance. |
StandardWebSocketClient(javax.websocket.WebSocketContainer webSocketContainer)
Constructor accepting an existing
WebSocketContainer instance. |
Modifier and Type | Method and Description |
---|---|
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.
|
AsyncListenableTaskExecutor |
getTaskExecutor()
Return the configured
TaskExecutor . |
java.util.Map<java.lang.String,java.lang.Object> |
getUserProperties()
The configured user properties.
|
void |
setTaskExecutor(AsyncListenableTaskExecutor taskExecutor)
Set an
AsyncListenableTaskExecutor to use when opening connections. |
void |
setUserProperties(java.util.Map<java.lang.String,java.lang.Object> userProperties)
The standard Java WebSocket API allows passing "user properties" to the
server via
userProperties . |
assertUri, doHandshake, doHandshake
public StandardWebSocketClient()
ContainerProvider.getWebSocketContainer()
to obtain a (new) WebSocketContainer
instance. Also see constructor
accepting existing WebSocketContainer
instance.public StandardWebSocketClient(javax.websocket.WebSocketContainer webSocketContainer)
WebSocketContainer
instance.
For XML configuration, see WebSocketContainerFactoryBean
. For Java
configuration, use ContainerProvider.getWebSocketContainer()
to obtain
the WebSocketContainer
instance.
public void setUserProperties(@Nullable java.util.Map<java.lang.String,java.lang.Object> userProperties)
userProperties
.
Use this property to configure one or more properties to be passed on
every handshake.public java.util.Map<java.lang.String,java.lang.Object> getUserProperties()
public void setTaskExecutor(@Nullable 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.
@Nullable 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.