类 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)WebSocketContainer
instance.StandardWebSocketClient(WebSocketContainer webSocketContainer)
Constructor accepting an existingWebSocketContainer
instance.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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 configuredTaskExecutor
.Map<String,Object>
getUserProperties()
The configured user properties, ornull
.void
setTaskExecutor(AsyncListenableTaskExecutor taskExecutor)
Set anAsyncListenableTaskExecutor
to use when opening connections.void
setUserProperties(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)WebSocketContainer
instance. Also see constructor accepting existingWebSocketContainer
instance.
StandardWebSocketClient
public StandardWebSocketClient(WebSocketContainer webSocketContainer)
Constructor accepting an existingWebSocketContainer
instance.For XML configuration, see
WebSocketContainerFactoryBean
. For Java configuration, useContainerProvider.getWebSocketContainer()
to obtain theWebSocketContainer
instance.
方法详细资料
setUserProperties
public void setUserProperties(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, ornull
.
setTaskExecutor
public void setTaskExecutor(AsyncListenableTaskExecutor taskExecutor)
Set anAsyncListenableTaskExecutor
to use when opening connections. If this property is set tonull
, calls to any of thedoHandshake
methods will block until the connection is established.By default, an instance of
SimpleAsyncTaskExecutor
is used.
getTaskExecutor
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)
从类复制的说明:AbstractWebSocketClient
Perform the actual handshake to establish a connection to the server.- 指定者:
doHandshakeInternal
在类中AbstractWebSocketClient
- 参数:
webSocketHandler
- the client-side handler for WebSocket messagesheaders
- 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
- attributes to associate with the WebSocketSession, i.e. viaWebSocketSession.getAttributes()
; currently always an empty map.- 返回:
- the established WebSocket session wrapped in a ListenableFuture.