Package io.undertow.websockets
Class ServerWebSocketContainer
java.lang.Object
io.undertow.websockets.ServerWebSocketContainer
- All Implemented Interfaces:
jakarta.websocket.server.ServerContainer,jakarta.websocket.WebSocketContainer,Closeable,AutoCloseable
public class ServerWebSocketContainer
extends Object
implements jakarta.websocket.server.ServerContainer, Closeable
ServerContainer implementation which allows to deploy endpoints for a server.- Author:
- Norman Maurer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic final class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intprotected final List<jakarta.websocket.Extension>protected final ObjectIntrospecterstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionServerWebSocketContainer(ObjectIntrospecter objectIntrospecter, ClassLoader classLoader, Supplier<io.netty.channel.EventLoopGroup> eventLoopSupplier, List<ContextSetupHandler> contextSetupHandlers, boolean dispatchToWorker, InetSocketAddress clientBindAddress, WebSocketReconnectHandler reconnectHandler, Supplier<Executor> executorSupplier, List<jakarta.websocket.Extension> installedExtensions, int maxFrameSize, Supplier<Principal> currentUserSupplier) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEndpoint(jakarta.websocket.server.ServerEndpointConfig endpoint) voidaddEndpoint(Class<?> endpoint) voidclose()voidclose(int waitTime) jakarta.websocket.SessionconnectToServer(jakarta.websocket.Endpoint endpointInstance, jakarta.websocket.ClientEndpointConfig config, io.undertow.websockets.WebsocketConnectionBuilder connectionBuilder) jakarta.websocket.SessionconnectToServer(jakarta.websocket.Endpoint endpointInstance, jakarta.websocket.ClientEndpointConfig config, URI path) jakarta.websocket.SessionconnectToServer(Class<?> aClass, io.undertow.websockets.WebsocketConnectionBuilder connectionBuilder) jakarta.websocket.SessionconnectToServer(Class<?> aClass, URI uri) jakarta.websocket.SessionconnectToServer(Class<? extends jakarta.websocket.Endpoint> endpointClass, jakarta.websocket.ClientEndpointConfig cec, URI path) jakarta.websocket.SessionconnectToServer(Object annotatedEndpointInstance, io.undertow.websockets.WebsocketConnectionBuilder connectionBuilder) jakarta.websocket.SessionconnectToServer(Object annotatedEndpointInstance, URI path) voidlongintlongintSet<jakarta.websocket.Extension>protected voidhandshakes(ConfiguredServerEndpoint config) handshakes(ConfiguredServerEndpoint config, List<io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandshaker> extensions) voidinvokeEndpointMethod(Runnable invocation, UndertowSession session) Directly invokes an endpoint method, without dispatching to an executorvoidinvokeEndpointMethod(Executor executor, Runnable invocation, UndertowSession session) Runs a web socket invocation, setting up the threads and dispatching a thread poolbooleanisClosed()booleanvoidpause(ServerWebSocketContainer.PauseListener listener) Pauses the containervoidresume()resumes a paused containervoidsetAsyncSendTimeout(long defaultAsyncSendTimeout) voidsetDefaultMaxBinaryMessageBufferSize(int defaultMaxBinaryMessageBufferSize) voidsetDefaultMaxSessionIdleTimeout(long timeout) voidsetDefaultMaxTextMessageBufferSize(int defaultMaxTextMessageBufferSize) voidupgradeHttpToWebSocket(Object req, Object res, jakarta.websocket.server.ServerEndpointConfig sec, Map<String, String> pathParameters) void
-
Field Details
-
TIMEOUT
- See Also:
-
DEFAULT_WEB_SOCKET_TIMEOUT_SECONDS
public static final int DEFAULT_WEB_SOCKET_TIMEOUT_SECONDS- See Also:
-
DEFAULT_MAX_FRAME_SIZE
public static final int DEFAULT_MAX_FRAME_SIZE- See Also:
-
objectIntrospecter
-
installedExtensions
-
installedExtensionNames
-
-
Constructor Details
-
ServerWebSocketContainer
public ServerWebSocketContainer(ObjectIntrospecter objectIntrospecter, ClassLoader classLoader, Supplier<io.netty.channel.EventLoopGroup> eventLoopSupplier, List<ContextSetupHandler> contextSetupHandlers, boolean dispatchToWorker, InetSocketAddress clientBindAddress, WebSocketReconnectHandler reconnectHandler, Supplier<Executor> executorSupplier, List<jakarta.websocket.Extension> installedExtensions, int maxFrameSize, Supplier<Principal> currentUserSupplier)
-
-
Method Details
-
getDefaultAsyncSendTimeout
public long getDefaultAsyncSendTimeout()- Specified by:
getDefaultAsyncSendTimeoutin interfacejakarta.websocket.WebSocketContainer
-
setAsyncSendTimeout
public void setAsyncSendTimeout(long defaultAsyncSendTimeout) - Specified by:
setAsyncSendTimeoutin interfacejakarta.websocket.WebSocketContainer
-
getExecutorSupplier
-
connectToServer
public jakarta.websocket.Session connectToServer(Object annotatedEndpointInstance, io.undertow.websockets.WebsocketConnectionBuilder connectionBuilder) throws jakarta.websocket.DeploymentException, IOException - Throws:
jakarta.websocket.DeploymentExceptionIOException
-
connectToServer
public jakarta.websocket.Session connectToServer(Object annotatedEndpointInstance, URI path) throws jakarta.websocket.DeploymentException, IOException - Specified by:
connectToServerin interfacejakarta.websocket.WebSocketContainer- Throws:
jakarta.websocket.DeploymentExceptionIOException
-
connectToServer
public jakarta.websocket.Session connectToServer(Class<?> aClass, io.undertow.websockets.WebsocketConnectionBuilder connectionBuilder) throws jakarta.websocket.DeploymentException, IOException - Throws:
jakarta.websocket.DeploymentExceptionIOException
-
connectToServer
public jakarta.websocket.Session connectToServer(Class<?> aClass, URI uri) throws jakarta.websocket.DeploymentException, IOException - Specified by:
connectToServerin interfacejakarta.websocket.WebSocketContainer- Throws:
jakarta.websocket.DeploymentExceptionIOException
-
connectToServer
public jakarta.websocket.Session connectToServer(jakarta.websocket.Endpoint endpointInstance, jakarta.websocket.ClientEndpointConfig config, URI path) throws jakarta.websocket.DeploymentException, IOException - Specified by:
connectToServerin interfacejakarta.websocket.WebSocketContainer- Throws:
jakarta.websocket.DeploymentExceptionIOException
-
connectToServer
public jakarta.websocket.Session connectToServer(jakarta.websocket.Endpoint endpointInstance, jakarta.websocket.ClientEndpointConfig config, io.undertow.websockets.WebsocketConnectionBuilder connectionBuilder) throws jakarta.websocket.DeploymentException, IOException - Throws:
jakarta.websocket.DeploymentExceptionIOException
-
connectToServer
public jakarta.websocket.Session connectToServer(Class<? extends jakarta.websocket.Endpoint> endpointClass, jakarta.websocket.ClientEndpointConfig cec, URI path) throws jakarta.websocket.DeploymentException, IOException - Specified by:
connectToServerin interfacejakarta.websocket.WebSocketContainer- Throws:
jakarta.websocket.DeploymentExceptionIOException
-
upgradeHttpToWebSocket
public void upgradeHttpToWebSocket(Object req, Object res, jakarta.websocket.server.ServerEndpointConfig sec, Map<String, String> pathParameters) throws IOException, jakarta.websocket.DeploymentException- Specified by:
upgradeHttpToWebSocketin interfacejakarta.websocket.server.ServerContainer- Throws:
IOExceptionjakarta.websocket.DeploymentException
-
getDefaultMaxSessionIdleTimeout
public long getDefaultMaxSessionIdleTimeout()- Specified by:
getDefaultMaxSessionIdleTimeoutin interfacejakarta.websocket.WebSocketContainer
-
setDefaultMaxSessionIdleTimeout
public void setDefaultMaxSessionIdleTimeout(long timeout) - Specified by:
setDefaultMaxSessionIdleTimeoutin interfacejakarta.websocket.WebSocketContainer
-
getDefaultMaxBinaryMessageBufferSize
public int getDefaultMaxBinaryMessageBufferSize()- Specified by:
getDefaultMaxBinaryMessageBufferSizein interfacejakarta.websocket.WebSocketContainer
-
setDefaultMaxBinaryMessageBufferSize
public void setDefaultMaxBinaryMessageBufferSize(int defaultMaxBinaryMessageBufferSize) - Specified by:
setDefaultMaxBinaryMessageBufferSizein interfacejakarta.websocket.WebSocketContainer
-
getDefaultMaxTextMessageBufferSize
public int getDefaultMaxTextMessageBufferSize()- Specified by:
getDefaultMaxTextMessageBufferSizein interfacejakarta.websocket.WebSocketContainer
-
setDefaultMaxTextMessageBufferSize
public void setDefaultMaxTextMessageBufferSize(int defaultMaxTextMessageBufferSize) - Specified by:
setDefaultMaxTextMessageBufferSizein interfacejakarta.websocket.WebSocketContainer
-
getInstalledExtensions
- Specified by:
getInstalledExtensionsin interfacejakarta.websocket.WebSocketContainer
-
invokeEndpointMethod
Runs a web socket invocation, setting up the threads and dispatching a thread poolUnfortunately we need to dispatch to a thread pool, because there is a good chance that the endpoint will use blocking IO methods. We suspend recieves while this is in progress, to make sure that we do not have multiple methods invoked at once.
- Parameters:
invocation- The task to run
-
invokeEndpointMethod
Directly invokes an endpoint method, without dispatching to an executor- Parameters:
invocation- The invocation
-
addEndpoint
- Specified by:
addEndpointin interfacejakarta.websocket.server.ServerContainer- Throws:
jakarta.websocket.DeploymentException
-
handleAddingFilterMapping
protected void handleAddingFilterMapping() -
addEndpoint
public void addEndpoint(jakarta.websocket.server.ServerEndpointConfig endpoint) throws jakarta.websocket.DeploymentException - Specified by:
addEndpointin interfacejakarta.websocket.server.ServerContainer- Throws:
jakarta.websocket.DeploymentException
-
validateDeployment
public void validateDeployment() -
deploymentComplete
public void deploymentComplete() -
getConfiguredServerEndpoints
-
close
public void close(int waitTime) -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
pause
Pauses the container- Parameters:
listener-
-
handshakes
public ServerWebSocketContainer.WebSocketHandshakeHolder handshakes(ConfiguredServerEndpoint config) -
handshakes
public ServerWebSocketContainer.WebSocketHandshakeHolder handshakes(ConfiguredServerEndpoint config, List<io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandshaker> extensions) -
resume
public void resume()resumes a paused container -
getWebSocketReconnectHandler
-
isClosed
public boolean isClosed() -
isDispatchToWorker
public boolean isDispatchToWorker()
-