Class WebSocketConnectionManager
java.lang.Object
org.springframework.web.socket.client.ConnectionManagerSupport
org.springframework.web.socket.client.WebSocketConnectionManager
- All Implemented Interfaces:
Lifecycle, Phased, SmartLifecycle
WebSocket
connection manager that connects
to the server via WebSocketClient and handles the session with a
WebSocketHandler.- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Sam Brannen
-
Field Summary
Fields inherited from class ConnectionManagerSupport
loggerFields inherited from interface SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketConnectionManager(WebSocketClient client, WebSocketHandler webSocketHandler, String uriTemplate, @Nullable Object... uriVariables) Constructor with the client to use and a handler to handle messages with.WebSocketConnectionManager(WebSocketClient client, WebSocketHandler webSocketHandler, URI uri) Variant ofWebSocketConnectionManager(WebSocketClient, WebSocketHandler, String, Object...)with a preparedURI. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidSubclasses implement this to close the connection.protected 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.booleanWhether the connection is open/trueor closed/false.protected voidSubclasses implement this to actually establish the connection.voidsetHeaders(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 ConnectionManagerSupport
getPhase, getUri, isAutoStartup, isRunning, setAutoStartup, setPhase, start, stop, stopMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SmartLifecycle
isPauseable
-
Constructor Details
-
WebSocketConnectionManager
public WebSocketConnectionManager(WebSocketClient client, WebSocketHandler webSocketHandler, String uriTemplate, @Nullable Object... uriVariables) Constructor with the client to use and a handler to handle messages with. -
WebSocketConnectionManager
public WebSocketConnectionManager(WebSocketClient client, WebSocketHandler webSocketHandler, URI uri) Variant ofWebSocketConnectionManager(WebSocketClient, WebSocketHandler, String, Object...)with a preparedURI.- Since:
- 6.0.5
-
-
Method Details
-
setSubProtocols
-
getSubProtocols
-
setOrigin
-
getOrigin
-
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
-
isConnected
public boolean isConnected()Description copied from class:ConnectionManagerSupportWhether the connection is open/trueor closed/false.- Specified by:
isConnectedin classConnectionManagerSupport
-
openConnection
protected void openConnection()Description copied from class:ConnectionManagerSupportSubclasses implement this to actually establish the connection.- Specified by:
openConnectionin classConnectionManagerSupport
-
closeConnection
Description copied from class:ConnectionManagerSupportSubclasses implement this to close the connection.- Specified by:
closeConnectionin classConnectionManagerSupport- Throws:
Exception
-
decorateWebSocketHandler
Decorate the WebSocketHandler provided to the class constructor.By default
LoggingWebSocketHandlerDecoratoris added.
-