Package org.zkoss.zk.ui.http
Class ZKWebSocket
- java.lang.Object
-
- javax.websocket.server.ServerEndpointConfig.Configurator
-
- org.zkoss.zk.ui.http.ZKWebSocket
-
public final class ZKWebSocket extends javax.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
ZKWebSocket.ZKPrinciple
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONNECTION_UUID_PARAM
static java.lang.String
DESKTOP_ID_PARAM
-
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.
-
-
-
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
-
-
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 duringinitZkDesktop(Session, EndpointConfig)
- Overrides:
modifyHandshake
in classjavax.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 viagetDesktop(Session)
. This method is called during websocket endpoint onOpen. E.g.WebSocketEndPoint.onOpen(Session, EndpointConfig)
- Parameters:
wsession
- Websocket sessionconfig
- 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
-
-