类 StandardWebSocketClient
- java.lang.Object
- org.springframework.web.socket.client.AbstractWebSocketClient
- org.springframework.web.socket.client.standard.StandardWebSocketClient
- 所有已实现的接口:
WebSocketClient
public class StandardWebSocketClient extends AbstractWebSocketClient
A WebSocketClient based on standard Java WebSocket API.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
字段概要
从类继承的字段 org.springframework.web.socket.client.AbstractWebSocketClient
logger
构造器概要
构造器 构造器 说明 StandardWebSocketClient()Default constructor that callsContainerProvider.getWebSocketContainer()to obtain a (new)WebSocketContainerinstance.StandardWebSocketClient(WebSocketContainer webSocketContainer)Constructor accepting an existingWebSocketContainerinstance.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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.AsyncListenableTaskExecutorgetTaskExecutor()Return the configuredTaskExecutor.Map<String,Object>getUserProperties()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.从类继承的方法 org.springframework.web.socket.client.AbstractWebSocketClient
assertUri, doHandshake, doHandshake
构造器详细资料
StandardWebSocketClient
public StandardWebSocketClient()
Default constructor that callsContainerProvider.getWebSocketContainer()to obtain a (new)WebSocketContainerinstance. Also see constructor accepting existingWebSocketContainerinstance.
StandardWebSocketClient
public StandardWebSocketClient(WebSocketContainer webSocketContainer)
Constructor accepting an existingWebSocketContainerinstance.For XML configuration, see
WebSocketContainerFactoryBean. For Java configuration, useContainerProvider.getWebSocketContainer()to obtain theWebSocketContainerinstance.
方法详细资料
setUserProperties
public void setUserProperties(@Nullable Map<String,Object> userProperties)
The 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.
getUserProperties
public Map<String,Object> getUserProperties()
The configured user properties.
setTaskExecutor
public void setTaskExecutor(@Nullable AsyncListenableTaskExecutor taskExecutor)
Set 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.
getTaskExecutor
@Nullable public AsyncListenableTaskExecutor getTaskExecutor()
Return the configuredTaskExecutor.
doHandshakeInternal
protected ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler webSocketHandler, HttpHeaders headers, URI uri, List<String> protocols, List<WebSocketExtension> extensions, Map<String,Object> attributes)
从类复制的说明:AbstractWebSocketClientPerform the actual handshake to establish a connection to the server.- 指定者:
doHandshakeInternal在类中AbstractWebSocketClient- 参数:
webSocketHandler- the client-side handler for WebSocket messagesheaders- the HTTP headers to use for the handshake, with unwanted (forbidden) headers filtered out (nevernull)uri- the target URI for the handshake (nevernull)protocols- requested sub-protocols, or an empty listextensions- requested WebSocket extensions, or an empty listattributes- the attributes to associate with the WebSocketSession, i.e. viaWebSocketSession.getAttributes(); currently always an empty map.- 返回:
- the established WebSocket session wrapped in a ListenableFuture.