Class WebSocketConnectionManager
java.lang.Object
org.springframework.web.socket.client.ConnectionManagerSupport
org.springframework.web.socket.client.WebSocketConnectionManager
- All Implemented Interfaces:
Lifecycle,Phased,SmartLifecycle
A WebSocket connection manager that is given a URI, a
WebSocketClient, and a
WebSocketHandler, connects to a WebSocket server through ConnectionManagerSupport.start() and
ConnectionManagerSupport.stop() methods. If ConnectionManagerSupport.setAutoStartup(boolean) is set to true
this will be done automatically when the Spring ApplicationContext is refreshed.- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Sam Brannen
-
Field Summary
Fields inherited from class org.springframework.web.socket.client.ConnectionManagerSupport
loggerFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketConnectionManager(WebSocketClient client, WebSocketHandler webSocketHandler, String uriTemplate, Object... uriVariables) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected WebSocketHandlerdecorateWebSocketHandler(WebSocketHandler handler) Decorate the WebSocketHandler provided to the class constructor.Return the default headers for the WebSocket handshake request.Return the configured origin.Return the configured sub-protocols to use.protected booleanprotected voidvoidsetHeaders(HttpHeaders headers) Provide default headers to add to the WebSocket handshake request.voidSet the origin to use.voidsetSubProtocols(List<String> protocols) Set the sub-protocols to use.voidvoidMethods inherited from class org.springframework.web.socket.client.ConnectionManagerSupport
getPhase, getUri, isAutoStartup, isRunning, setAutoStartup, setPhase, start, stop, stop
-
Constructor Details
-
WebSocketConnectionManager
public WebSocketConnectionManager(WebSocketClient client, WebSocketHandler webSocketHandler, String uriTemplate, Object... uriVariables)
-
-
Method Details
-
decorateWebSocketHandler
Decorate the WebSocketHandler provided to the class constructor.By default
LoggingWebSocketHandlerDecoratoris added. -
setSubProtocols
Set the sub-protocols to use. If configured, specified sub-protocols will be requested in the handshake through theSec-WebSocket-Protocolheader. The resulting WebSocket session will contain the protocol accepted by the server, if any. -
getSubProtocols
Return the configured sub-protocols to use. -
setOrigin
Set the origin to use. -
getOrigin
Return the configured origin. -
setHeaders
Provide default headers to add to the WebSocket handshake request. -
getHeaders
Return the default headers for the WebSocket handshake request. -
startInternal
public void startInternal()- Overrides:
startInternalin classConnectionManagerSupport
-
stopInternal
- Overrides:
stopInternalin classConnectionManagerSupport- Throws:
Exception
-
openConnection
protected void openConnection()- Specified by:
openConnectionin classConnectionManagerSupport
-
closeConnection
- Specified by:
closeConnectionin classConnectionManagerSupport- Throws:
Exception
-
isConnected
protected boolean isConnected()- Specified by:
isConnectedin classConnectionManagerSupport
-