Class ZKWebSocket


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

      Constructors 
      Constructor Description
      ZKWebSocket()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Desktop getDesktop​(javax.websocket.Session wsession)
      Returns the desktop from the given websocket session.
      static Storage getDesktopStorage​(javax.websocket.Session wsession)
      Returns a storage in desktop scope from the given websocket session.
      static void initZkDesktop​(javax.websocket.Session wsession, javax.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​(javax.websocket.server.ServerEndpointConfig config, javax.websocket.server.HandshakeRequest request, javax.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 javax.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 Detail

      • DESKTOP_ID_PARAM

        public static final java.lang.String DESKTOP_ID_PARAM
        See Also:
        Constant Field Values
      • CONNECTION_UUID_PARAM

        public static final java.lang.String CONNECTION_UUID_PARAM
        See Also:
        Constant Field Values
    • Constructor Detail

      • ZKWebSocket

        public ZKWebSocket()
    • Method Detail

      • modifyHandshake

        public void modifyHandshake​(javax.websocket.server.ServerEndpointConfig config,
                                    javax.websocket.server.HandshakeRequest request,
                                    javax.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 javax.websocket.server.ServerEndpointConfig.Configurator
        Parameters:
        config -
        request -
        response -
      • initZkDesktop

        public static void initZkDesktop​(javax.websocket.Session wsession,
                                         javax.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​(javax.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​(javax.websocket.Session wsession)
        Returns the desktop from the given websocket session.
        Parameters:
        wsession - websocket session
        Returns:
        a desktop, null if desktop not found