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
  • Field Details

    • TIMEOUT

      public static final String 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

      protected final ObjectIntrospecter objectIntrospecter
    • installedExtensions

      protected final List<jakarta.websocket.Extension> installedExtensions
    • installedExtensionNames

      protected final Set<String> installedExtensionNames
  • Constructor Details

  • Method Details

    • getDefaultAsyncSendTimeout

      public long getDefaultAsyncSendTimeout()
      Specified by:
      getDefaultAsyncSendTimeout in interface jakarta.websocket.WebSocketContainer
    • setAsyncSendTimeout

      public void setAsyncSendTimeout(long defaultAsyncSendTimeout)
      Specified by:
      setAsyncSendTimeout in interface jakarta.websocket.WebSocketContainer
    • getExecutorSupplier

      protected Supplier<Executor> getExecutorSupplier()
    • connectToServer

      public jakarta.websocket.Session connectToServer(Object annotatedEndpointInstance, io.undertow.websockets.WebsocketConnectionBuilder connectionBuilder) throws jakarta.websocket.DeploymentException, IOException
      Throws:
      jakarta.websocket.DeploymentException
      IOException
    • connectToServer

      public jakarta.websocket.Session connectToServer(Object annotatedEndpointInstance, URI path) throws jakarta.websocket.DeploymentException, IOException
      Specified by:
      connectToServer in interface jakarta.websocket.WebSocketContainer
      Throws:
      jakarta.websocket.DeploymentException
      IOException
    • connectToServer

      public jakarta.websocket.Session connectToServer(Class<?> aClass, io.undertow.websockets.WebsocketConnectionBuilder connectionBuilder) throws jakarta.websocket.DeploymentException, IOException
      Throws:
      jakarta.websocket.DeploymentException
      IOException
    • connectToServer

      public jakarta.websocket.Session connectToServer(Class<?> aClass, URI uri) throws jakarta.websocket.DeploymentException, IOException
      Specified by:
      connectToServer in interface jakarta.websocket.WebSocketContainer
      Throws:
      jakarta.websocket.DeploymentException
      IOException
    • connectToServer

      public jakarta.websocket.Session connectToServer(jakarta.websocket.Endpoint endpointInstance, jakarta.websocket.ClientEndpointConfig config, URI path) throws jakarta.websocket.DeploymentException, IOException
      Specified by:
      connectToServer in interface jakarta.websocket.WebSocketContainer
      Throws:
      jakarta.websocket.DeploymentException
      IOException
    • 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.DeploymentException
      IOException
    • 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:
      connectToServer in interface jakarta.websocket.WebSocketContainer
      Throws:
      jakarta.websocket.DeploymentException
      IOException
    • upgradeHttpToWebSocket

      public void upgradeHttpToWebSocket(Object req, Object res, jakarta.websocket.server.ServerEndpointConfig sec, Map<String,String> pathParameters) throws IOException, jakarta.websocket.DeploymentException
      Specified by:
      upgradeHttpToWebSocket in interface jakarta.websocket.server.ServerContainer
      Throws:
      IOException
      jakarta.websocket.DeploymentException
    • getDefaultMaxSessionIdleTimeout

      public long getDefaultMaxSessionIdleTimeout()
      Specified by:
      getDefaultMaxSessionIdleTimeout in interface jakarta.websocket.WebSocketContainer
    • setDefaultMaxSessionIdleTimeout

      public void setDefaultMaxSessionIdleTimeout(long timeout)
      Specified by:
      setDefaultMaxSessionIdleTimeout in interface jakarta.websocket.WebSocketContainer
    • getDefaultMaxBinaryMessageBufferSize

      public int getDefaultMaxBinaryMessageBufferSize()
      Specified by:
      getDefaultMaxBinaryMessageBufferSize in interface jakarta.websocket.WebSocketContainer
    • setDefaultMaxBinaryMessageBufferSize

      public void setDefaultMaxBinaryMessageBufferSize(int defaultMaxBinaryMessageBufferSize)
      Specified by:
      setDefaultMaxBinaryMessageBufferSize in interface jakarta.websocket.WebSocketContainer
    • getDefaultMaxTextMessageBufferSize

      public int getDefaultMaxTextMessageBufferSize()
      Specified by:
      getDefaultMaxTextMessageBufferSize in interface jakarta.websocket.WebSocketContainer
    • setDefaultMaxTextMessageBufferSize

      public void setDefaultMaxTextMessageBufferSize(int defaultMaxTextMessageBufferSize)
      Specified by:
      setDefaultMaxTextMessageBufferSize in interface jakarta.websocket.WebSocketContainer
    • getInstalledExtensions

      public Set<jakarta.websocket.Extension> getInstalledExtensions()
      Specified by:
      getInstalledExtensions in interface jakarta.websocket.WebSocketContainer
    • invokeEndpointMethod

      public void invokeEndpointMethod(Executor executor, Runnable invocation, UndertowSession session)
      Runs a web socket invocation, setting up the threads and dispatching a thread pool

      Unfortunately 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

      public void invokeEndpointMethod(Runnable invocation, UndertowSession session)
      Directly invokes an endpoint method, without dispatching to an executor
      Parameters:
      invocation - The invocation
    • addEndpoint

      public void addEndpoint(Class<?> endpoint) throws jakarta.websocket.DeploymentException
      Specified by:
      addEndpoint in interface jakarta.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:
      addEndpoint in interface jakarta.websocket.server.ServerContainer
      Throws:
      jakarta.websocket.DeploymentException
    • validateDeployment

      public void validateDeployment()
    • deploymentComplete

      public void deploymentComplete()
    • getConfiguredServerEndpoints

      public List<ConfiguredServerEndpoint> getConfiguredServerEndpoints()
    • close

      public void close(int waitTime)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • pause

      public void pause(ServerWebSocketContainer.PauseListener listener)
      Pauses the container
      Parameters:
      listener -
    • handshakes

    • 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

      public WebSocketReconnectHandler getWebSocketReconnectHandler()
    • isClosed

      public boolean isClosed()
    • isDispatchToWorker

      public boolean isDispatchToWorker()