Class ClientWebSocketContainer
java.lang.Object
org.springframework.integration.websocket.IntegrationWebSocketContainer
org.springframework.integration.websocket.ClientWebSocketContainer
- All Implemented Interfaces:
DisposableBean,Lifecycle,Phased,SmartLifecycle
public final class ClientWebSocketContainer
extends IntegrationWebSocketContainer
implements SmartLifecycle
The
IntegrationWebSocketContainer implementation for the client
Web-Socket connection.
Represent the composition over an internal ConnectionManagerSupport
implementation.
Accepts the clientSession WebSocketSession on
ConnectionManagerSupport.openConnection()
event, which can be accessed from this container using getSession(String).
- Since:
- 4.1
- Author:
- Artem Bilan, Gary Russell, Christian Tzolov
-
Field Summary
Fields inherited from class org.springframework.integration.websocket.IntegrationWebSocketContainer
DEFAULT_SEND_BUFFER_SIZE, DEFAULT_SEND_TIME_LIMIT, lock, logger, sessionsFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionClientWebSocketContainer(WebSocketClient client, String uriTemplate, Object... uriVariables) ClientWebSocketContainer(WebSocketClient client, URI uri) Constructor with a preparedURI. -
Method Summary
Modifier and TypeMethodDescriptionintgetPhase()getSession(@Nullable String sessionId) Return theclientSessionWebSocketSession.booleanbooleanReturntrueif theclientSessionis opened.booleanvoidsetAutoStartup(boolean autoStartup) voidsetConnectionTimeout(int connectionTimeout) Set the connection timeout in seconds; default: 10.voidsetHeaders(HttpHeaders headers) voidsetHeadersMap(Map<String, String> headers) voidvoidsetPhase(int phase) voidstart()voidstop()voidMethods inherited from class org.springframework.integration.websocket.IntegrationWebSocketContainer
addSupportedProtocols, closeSession, destroy, getSessions, getSubProtocols, getWebSocketHandler, setMessageListener, setSendBufferOverflowStrategy, setSendBufferSizeLimit, setSendTimeLimit, setSupportedProtocols, setWebSocketHandlerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.SmartLifecycle
isPauseable
-
Constructor Details
-
ClientWebSocketContainer
-
ClientWebSocketContainer
Constructor with a preparedURI.- Parameters:
client- theWebSocketClientto use.uri- the url to connect to- Since:
- 6.1
-
-
Method Details
-
setOrigin
-
setHeadersMap
-
setHeaders
-
setConnectionTimeout
public void setConnectionTimeout(int connectionTimeout) Set the connection timeout in seconds; default: 10.- Parameters:
connectionTimeout- the timeout in seconds.- Since:
- 4.2
-
getSession
Return theclientSessionWebSocketSession. Independently of provided argument, this method always returns only the establishedclientSession- Overrides:
getSessionin classIntegrationWebSocketContainer- Parameters:
sessionId- thesessionId. Can benull.- Returns:
- the
clientSession, if established.
-
setAutoStartup
public void setAutoStartup(boolean autoStartup) -
setPhase
public void setPhase(int phase) -
isConnected
public boolean isConnected()Returntrueif theclientSessionis opened.- Returns:
- the
WebSocketSession.isOpen()state. - Since:
- 4.2.6
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartupin interfaceSmartLifecycle
-
getPhase
public int getPhase()- Specified by:
getPhasein interfacePhased- Specified by:
getPhasein interfaceSmartLifecycle
-
isRunning
-
start
-
stop
-
stop
- Specified by:
stopin interfaceSmartLifecycle
-