Class StandardWebSocketClient
java.lang.Object
org.springframework.web.socket.client.AbstractWebSocketClient
org.springframework.web.socket.client.standard.StandardWebSocketClient
- All Implemented Interfaces:
- WebSocketClient
A WebSocketClient based on standard Java WebSocket API.
- Since:
- 4.0
- Author:
- Rossen Stoyanchev
- 
Field SummaryFields inherited from class org.springframework.web.socket.client.AbstractWebSocketClientlogger
- 
Constructor SummaryConstructorsConstructorDescriptionDefault constructor that callsContainerProvider.getWebSocketContainer()to obtain a (new)WebSocketContainerinstance.StandardWebSocketClient(WebSocketContainer webSocketContainer) Constructor accepting an existingWebSocketContainerinstance.
- 
Method SummaryModifier and TypeMethodDescriptionprotected 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.Return the configuredTaskExecutor.The configured user properties.voidsetTaskExecutor(AsyncListenableTaskExecutor taskExecutor) Set anAsyncListenableTaskExecutorto use when opening connections.voidsetUserProperties(Map<String, Object> userProperties) The standard Java WebSocket API allows passing "user properties" to the server viauserProperties.Methods inherited from class org.springframework.web.socket.client.AbstractWebSocketClientassertUri, doHandshake, doHandshake
- 
Constructor Details- 
StandardWebSocketClientpublic StandardWebSocketClient()Default constructor that callsContainerProvider.getWebSocketContainer()to obtain a (new)WebSocketContainerinstance. Also see constructor accepting existingWebSocketContainerinstance.
- 
StandardWebSocketClientConstructor accepting an existingWebSocketContainerinstance.For XML configuration, see WebSocketContainerFactoryBean. For Java configuration, useContainerProvider.getWebSocketContainer()to obtain theWebSocketContainerinstance.
 
- 
- 
Method Details- 
setUserPropertiesThe standard Java WebSocket API allows passing "user properties" to the server viauserProperties. Use this property to configure one or more properties to be passed on every handshake.
- 
getUserPropertiesThe configured user properties.
- 
setTaskExecutorSet anAsyncListenableTaskExecutorto use when opening connections. If this property is set tonull, calls to any of thedoHandshakemethods will block until the connection is established.By default, an instance of SimpleAsyncTaskExecutoris used.
- 
getTaskExecutorReturn the configuredTaskExecutor.
- 
doHandshakeInternalprotected ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler webSocketHandler, HttpHeaders headers, URI uri, List<String> protocols, List<WebSocketExtension> extensions, Map<String, Object> attributes) Description copied from class:AbstractWebSocketClientPerform the actual handshake to establish a connection to the server.- Specified by:
- doHandshakeInternalin class- AbstractWebSocketClient
- Parameters:
- webSocketHandler- the client-side handler for WebSocket messages
- headers- the 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 list
- extensions- requested WebSocket extensions, or an empty list
- attributes- the attributes to associate with the WebSocketSession, i.e. via- WebSocketSession.getAttributes(); currently always an empty map.
- Returns:
- the established WebSocket session wrapped in a ListenableFuture.
 
 
-