Class SecureWebsocket<T extends BaseWebsocket>
java.lang.Object
ch.tocco.nice2.web.core.api.websocket.SecureWebsocket<T>
- All Implemented Interfaces:
WebSocket<T>
- Direct Known Subclasses:
AnonymousWebsocket, ToccoWebsocketDefinition
public abstract class SecureWebsocket<T extends BaseWebsocket>
extends Object
implements WebSocket<T>
Base implementation of
WebSocket that verifies the authentication
during the handshake request and supports sending messages to specific users.
The actual implementation must extend BaseWebsocket.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleanfinal TCreate an instance of the WebSocket implementation.protected abstract Tprotected SecurityContextfinal voidonHandshake(Map<String, Object> userProperties) Called when the WebSocket connection is initialized.voidonLogout(LogoutEvent event) voidsendMessage(Callable<Optional<String>> message) Sends a message to all clients that are connected to this endpoint.voidsendMessageToOrigin(String originId, Callable<Optional<String>> message) Sends a message to a certain client.voidsendMessageToUser(String username, Callable<Optional<String>> message) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface WebSocket
getPath, webSocketClass
-
Field Details
-
CONTEXT_KEY
- See Also:
-
BUSINESS_UNIT_KEY
- See Also:
-
ORIGIN_ID_KEY
- See Also:
-
-
Constructor Details
-
SecureWebsocket
-
-
Method Details
-
allowAnonymous
protected abstract boolean allowAnonymous()- Returns:
- true if unauthenticated users are supported by this web socket
-
createWebSocketInstance
Description copied from interface:WebSocketCreate an instance of the WebSocket implementation. This method allows custom initialization of the WebSocket class.A new instance will be created for every new WebSocket connection.
- Specified by:
createWebSocketInstancein interfaceWebSocket<T extends BaseWebsocket>
-
onLogout
-
doCreateWebSocketInstance
-
getSecurityContext
-
onHandshake
Description copied from interface:WebSocketCalled when the WebSocket connection is initialized. This is called from a normal HTTP Request, so authentication data is still available at this point.Data stored in the given map will later be available from the WebSocket session.
- Specified by:
onHandshakein interfaceWebSocket<T extends BaseWebsocket>
-
sendMessage
Description copied from interface:WebSocketSends a message to all clients that are connected to this endpoint.The given callable will be evaluated using the security and business unit contexts of the client.
- Specified by:
sendMessagein interfaceWebSocket<T extends BaseWebsocket>
-
sendMessageToOrigin
Description copied from interface:WebSocketSends a message to a certain client.The given callable will be evaluated using the security and business unit contexts of the client.
- Specified by:
sendMessageToOriginin interfaceWebSocket<T extends BaseWebsocket>
-
sendMessageToUser
- Specified by:
sendMessageToUserin interfaceWebSocket<T extends BaseWebsocket>
-