类 WebSocketConnectionManager
- java.lang.Object
- org.springframework.web.socket.client.ConnectionManagerSupport
- org.springframework.web.socket.client.WebSocketConnectionManager
- 所有已实现的接口:
Lifecycle
,Phased
,SmartLifecycle
public class WebSocketConnectionManager extends ConnectionManagerSupport
A WebSocket connection manager that is given a URI, aWebSocketClient
, and aWebSocketHandler
, connects to a WebSocket server throughConnectionManagerSupport.start()
andConnectionManagerSupport.stop()
methods. IfConnectionManagerSupport.setAutoStartup(boolean)
is set totrue
this will be done automatically when the Spring ApplicationContext is refreshed.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
字段概要
从类继承的字段 org.springframework.web.socket.client.ConnectionManagerSupport
logger
构造器概要
构造器 构造器 说明 WebSocketConnectionManager(WebSocketClient client, WebSocketHandler webSocketHandler, String uriTemplate, Object... uriVariables)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected void
closeConnection()
protected WebSocketHandler
decorateWebSocketHandler(WebSocketHandler handler)
Decorate the WebSocketHandler provided to the class constructor.HttpHeaders
getHeaders()
Return the default headers for the WebSocket handshake request.String
getOrigin()
Return the configured origin.List<String>
getSubProtocols()
Return the configured sub-protocols to use.protected boolean
isConnected()
protected void
openConnection()
void
setHeaders(HttpHeaders headers)
Provide default headers to add to the WebSocket handshake request.void
setOrigin(String origin)
Set the origin to use.void
setSubProtocols(List<String> protocols)
Set the sub-protocols to use.void
startInternal()
void
stopInternal()
从类继承的方法 org.springframework.web.socket.client.ConnectionManagerSupport
getPhase, getUri, isAutoStartup, isRunning, setAutoStartup, setPhase, start, stop, stop
构造器详细资料
WebSocketConnectionManager
public WebSocketConnectionManager(WebSocketClient client, WebSocketHandler webSocketHandler, String uriTemplate, Object... uriVariables)
方法详细资料
decorateWebSocketHandler
protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler handler)
Decorate the WebSocketHandler provided to the class constructor.By default
LoggingWebSocketHandlerDecorator
is added.
setSubProtocols
public void setSubProtocols(List<String> protocols)
Set the sub-protocols to use. If configured, specified sub-protocols will be requested in the handshake through theSec-WebSocket-Protocol
header. The resulting WebSocket session will contain the protocol accepted by the server, if any.
getSubProtocols
public List<String> getSubProtocols()
Return the configured sub-protocols to use.
setHeaders
public void setHeaders(HttpHeaders headers)
Provide default headers to add to the WebSocket handshake request.
getHeaders
public HttpHeaders getHeaders()
Return the default headers for the WebSocket handshake request.
startInternal
public void startInternal()
stopInternal
public void stopInternal() throws Exception
openConnection
protected void openConnection()
closeConnection
protected void closeConnection() throws Exception
- 指定者:
closeConnection
在类中ConnectionManagerSupport
- 抛出:
Exception
isConnected
protected boolean isConnected()
- 指定者:
isConnected
在类中ConnectionManagerSupport