Package org.apache.tomcat.websocket
Class WsWebSocketContainer
java.lang.Object
org.apache.tomcat.websocket.WsWebSocketContainer
- All Implemented Interfaces:
- WebSocketContainer,- BackgroundProcess
- Direct Known Subclasses:
- WsServerContainer
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidconnectToServer(Endpoint endpoint, ClientEndpointConfig clientEndpointConfiguration, URI path) Creates a new connection to the WebSocket.connectToServer(Class<?> annotatedEndpointClass, URI path) connectToServer(Class<? extends Endpoint> clazz, ClientEndpointConfig clientEndpointConfiguration, URI path) Creates a new connection to the WebSocket.connectToServer(Object pojo, URI path) voiddestroy()Cleans up the resources still in use by WebSocket sessions created from this container.longGet the default timeout for sending a message asynchronously.intGet the default maximum buffer size for binary messages.longGet the current default session idle timeout.intGet the default maximum buffer size for text messages.Get the installed extensions.protected InstanceManagergetInstanceManager(ClassLoader classLoader) intThe default value is 10 which means session expirations are processed every 10 seconds.protected voidregisterSession(Object key, WsSession wsSession) voidsetAsyncSendTimeout(long timeout) Set the default timeout for sending a message asynchronously.voidsetDefaultMaxBinaryMessageBufferSize(int max) Set the default maximum buffer size for binary messages.voidsetDefaultMaxSessionIdleTimeout(long timeout) Set the default session idle timeout.voidsetDefaultMaxTextMessageBufferSize(int max) Set the default maximum buffer size for text messages.protected voidsetInstanceManager(InstanceManager instanceManager) voidsetProcessPeriod(int period) protected voidunregisterSession(Object key, WsSession wsSession) 
- 
Constructor Details- 
WsWebSocketContainerpublic WsWebSocketContainer()
 
- 
- 
Method Details- 
getInstanceManager
- 
setInstanceManager
- 
connectToServer- Specified by:
- connectToServerin interface- WebSocketContainer
- Throws:
- DeploymentException
 
- 
connectToServerpublic Session connectToServer(Class<?> annotatedEndpointClass, URI path) throws DeploymentException - Specified by:
- connectToServerin interface- WebSocketContainer
- Throws:
- DeploymentException
 
- 
connectToServerpublic Session connectToServer(Class<? extends Endpoint> clazz, ClientEndpointConfig clientEndpointConfiguration, URI path) throws DeploymentException Description copied from interface:jakarta.websocket.WebSocketContainerCreates a new connection to the WebSocket.- Specified by:
- connectToServerin interface- WebSocketContainer
- Parameters:
- clazz- An instance of this class will be created to handle responses from the server
- clientEndpointConfiguration- Used to configure the new connection
- path- The full URL of the WebSocket endpoint to connect to
- Returns:
- The WebSocket session for the connection
- Throws:
- DeploymentException- If the connection cannot be established
 
- 
connectToServerpublic Session connectToServer(Endpoint endpoint, ClientEndpointConfig clientEndpointConfiguration, URI path) throws DeploymentException Description copied from interface:jakarta.websocket.WebSocketContainerCreates a new connection to the WebSocket.- Specified by:
- connectToServerin interface- WebSocketContainer
- Parameters:
- endpoint- The endpoint instance that will handle responses from the server
- clientEndpointConfiguration- Used to configure the new connection
- path- The full URL of the WebSocket endpoint to connect to
- Returns:
- The WebSocket session for the connection
- Throws:
- DeploymentException- If the connection cannot be established
 
- 
registerSession
- 
unregisterSession
- 
getDefaultMaxSessionIdleTimeoutpublic long getDefaultMaxSessionIdleTimeout()Description copied from interface:jakarta.websocket.WebSocketContainerGet the current default session idle timeout.- Specified by:
- getDefaultMaxSessionIdleTimeoutin interface- WebSocketContainer
- Returns:
- The current default session idle timeout in milliseconds. Zero or negative values indicate an infinite timeout.
 
- 
setDefaultMaxSessionIdleTimeoutpublic void setDefaultMaxSessionIdleTimeout(long timeout) Description copied from interface:jakarta.websocket.WebSocketContainerSet the default session idle timeout.- Specified by:
- setDefaultMaxSessionIdleTimeoutin interface- WebSocketContainer
- Parameters:
- timeout- The new default session idle timeout in milliseconds. Zero or negative values indicate an infinite timeout.
 
- 
getDefaultMaxBinaryMessageBufferSizepublic int getDefaultMaxBinaryMessageBufferSize()Description copied from interface:jakarta.websocket.WebSocketContainerGet the default maximum buffer size for binary messages.- Specified by:
- getDefaultMaxBinaryMessageBufferSizein interface- WebSocketContainer
- Returns:
- The current default maximum buffer size in bytes
 
- 
setDefaultMaxBinaryMessageBufferSizepublic void setDefaultMaxBinaryMessageBufferSize(int max) Description copied from interface:jakarta.websocket.WebSocketContainerSet the default maximum buffer size for binary messages.- Specified by:
- setDefaultMaxBinaryMessageBufferSizein interface- WebSocketContainer
- Parameters:
- max- The new default maximum buffer size in bytes
 
- 
getDefaultMaxTextMessageBufferSizepublic int getDefaultMaxTextMessageBufferSize()Description copied from interface:jakarta.websocket.WebSocketContainerGet the default maximum buffer size for text messages.- Specified by:
- getDefaultMaxTextMessageBufferSizein interface- WebSocketContainer
- Returns:
- The current default maximum buffer size in characters
 
- 
setDefaultMaxTextMessageBufferSizepublic void setDefaultMaxTextMessageBufferSize(int max) Description copied from interface:jakarta.websocket.WebSocketContainerSet the default maximum buffer size for text messages.- Specified by:
- setDefaultMaxTextMessageBufferSizein interface- WebSocketContainer
- Parameters:
- max- The new default maximum buffer size in characters
 
- 
getInstalledExtensionsGet the installed extensions. Currently, this implementation does not support any extensions.- Specified by:
- getInstalledExtensionsin interface- WebSocketContainer
- Returns:
- The set of extensions that are supported by this WebSocket implementation.
 
- 
getDefaultAsyncSendTimeoutpublic long getDefaultAsyncSendTimeout()Get the default timeout for sending a message asynchronously. The default value for this implementation is -1.- Specified by:
- getDefaultAsyncSendTimeoutin interface- WebSocketContainer
- Returns:
- The current default timeout in milliseconds. A non-positive value means an infinite timeout.
 
- 
setAsyncSendTimeoutpublic void setAsyncSendTimeout(long timeout) Set the default timeout for sending a message asynchronously. The default value for this implementation is -1.- Specified by:
- setAsyncSendTimeoutin interface- WebSocketContainer
- Parameters:
- timeout- The new default timeout in milliseconds. A non-positive value means an infinite timeout.
 
- 
destroypublic void destroy()Cleans up the resources still in use by WebSocket sessions created from this container. This includes closing sessions and cancellingFutures associated with blocking read/writes.
- 
backgroundProcesspublic void backgroundProcess()- Specified by:
- backgroundProcessin interface- BackgroundProcess
 
- 
setProcessPeriodpublic void setProcessPeriod(int period) - Specified by:
- setProcessPeriodin interface- BackgroundProcess
 
- 
getProcessPeriodpublic int getProcessPeriod()The default value is 10 which means session expirations are processed every 10 seconds.- Specified by:
- getProcessPeriodin interface- BackgroundProcess
 
 
-