Class ZKWebSocket

java.lang.Object
jakarta.websocket.server.ServerEndpointConfig.Configurator
org.zkoss.zk.ui.http.ZKWebSocket

public final class ZKWebSocket extends jakarta.websocket.server.ServerEndpointConfig.Configurator
A web socket util class
Since:
8.0.0
Author:
jumperchen
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Desktop
    getDesktop(jakarta.websocket.Session wsession)
    Returns the desktop from the given websocket session.
    static Storage
    getDesktopStorage(jakarta.websocket.Session wsession)
    Returns a storage in desktop scope from the given websocket session.
    static void
    initZkDesktop(jakarta.websocket.Session wsession, jakarta.websocket.EndpointConfig config)
    Stores the zksession and desktop id into the websocket session userProperties, removes the temporary key/value from the endpoint userProperties.
    void
    modifyHandshake(jakarta.websocket.server.ServerEndpointConfig config, jakarta.websocket.server.HandshakeRequest request, jakarta.websocket.HandshakeResponse response)
    Retrieves the current zk session from handshake request and store this temporarily under a unique key ('${desktopid}|[${connection_uuid}]') inside the endpoint config userProperties.

    Methods inherited from class jakarta.websocket.server.ServerEndpointConfig.Configurator

    checkOrigin, getEndpointInstance, getNegotiatedExtensions, getNegotiatedSubprotocol

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ZKWebSocket

      public ZKWebSocket()
  • Method Details

    • modifyHandshake

      public void modifyHandshake(jakarta.websocket.server.ServerEndpointConfig config, jakarta.websocket.server.HandshakeRequest request, jakarta.websocket.HandshakeResponse response)
      Retrieves the current zk session from handshake request and store this temporarily under a unique key ('${desktopid}|[${connection_uuid}]') inside the endpoint config userProperties. This is temp key is removed during initZkDesktop(Session, EndpointConfig)
      Overrides:
      modifyHandshake in class jakarta.websocket.server.ServerEndpointConfig.Configurator
      Parameters:
      config -
      request -
      response -
    • initZkDesktop

      public static void initZkDesktop(jakarta.websocket.Session wsession, jakarta.websocket.EndpointConfig config)
      Stores the zksession and desktop id into the websocket session userProperties, removes the temporary key/value from the endpoint userProperties. After calling this method the zk desktop is available via getDesktop(Session). This method is called during websocket endpoint onOpen. E.g. WebSocketEndPoint.onOpen(Session, EndpointConfig)
      Parameters:
      wsession - Websocket session
      config - Endpoint config
      Since:
      8.6.4
    • getDesktopStorage

      public static Storage getDesktopStorage(jakarta.websocket.Session wsession)
      Returns a storage in desktop scope from the given websocket session.
      Parameters:
      wsession - websocket session
      Returns:
      a storage, null if desktop not found.
    • getDesktop

      public static Desktop getDesktop(jakarta.websocket.Session wsession)
      Returns the desktop from the given websocket session.
      Parameters:
      wsession - websocket session
      Returns:
      a desktop, null if desktop not found