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
-
Field Summary
Fields inherited from class org.springframework.integration.websocket.IntegrationWebSocketContainer
DEFAULT_SEND_BUFFER_SIZE, DEFAULT_SEND_TIME_LIMIT, logger, sessions, webSocketHandler
-
Constructor Summary
Constructors Constructor Description ClientWebSocketContainer(WebSocketClient client, String uriTemplate, Object... uriVariables)
-
Method Summary
Modifier and Type Method Description int
getPhase()
WebSocketSession
getSession(String sessionId)
Return theclientSession
WebSocketSession
.boolean
isAutoStartup()
boolean
isConnected()
Returntrue
if theclientSession
is opened.boolean
isRunning()
void
setAutoStartup(boolean autoStartup)
void
setConnectionTimeout(int connectionTimeout)
Set the connection timeout in seconds; default: 10.void
setHeaders(HttpHeaders headers)
void
setHeadersMap(Map<String,String> headers)
void
setOrigin(String origin)
void
setPhase(int phase)
void
start()
void
stop()
void
stop(Runnable callback)
Methods inherited from class org.springframework.integration.websocket.IntegrationWebSocketContainer
addSupportedProtocols, closeSession, destroy, getSessions, getSubProtocols, getWebSocketHandler, setMessageListener, setSendBufferSizeLimit, setSendTimeLimit, setSupportedProtocols
-
Constructor Details
-
ClientWebSocketContainer
public ClientWebSocketContainer(WebSocketClient client, String uriTemplate, Object... uriVariables)
-
-
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 theclientSession
WebSocketSession
. Independently of provided argument, this method always returns only the establishedclientSession
- Overrides:
getSession
in 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()Returntrue
if theclientSession
is opened.- Returns:
- the
WebSocketSession.isOpen()
state. - Since:
- 4.2.6
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartup
in interfaceSmartLifecycle
-
getPhase
public int getPhase()- Specified by:
getPhase
in interfacePhased
- Specified by:
getPhase
in interfaceSmartLifecycle
-
isRunning
public boolean isRunning() -
start
public void start() -
stop
public void stop() -
stop
- Specified by:
stop
in interfaceSmartLifecycle
-