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
,NotificationWebsocketDefinition
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract boolean
final T
Create an instance of the WebSocket implementation.protected abstract T
protected SecurityContext
final void
onHandshake
(Map<String, Object> userProperties) Called when the WebSocket connection is initialized.void
onLogout
(LogoutEvent event) void
sendMessage
(Callable<Optional<String>> message) Sends a message to all clients that are connected to this endpoint.void
sendMessageToOrigin
(String originId, Callable<Optional<String>> message) Sends a message to a certain client.void
sendMessageToUser
(String username, Callable<Optional<String>> message) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.web.core.api.websocket.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:WebSocket
Create 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:
createWebSocketInstance
in interfaceWebSocket<T extends BaseWebsocket>
-
onLogout
-
doCreateWebSocketInstance
-
getSecurityContext
-
onHandshake
Description copied from interface:WebSocket
Called 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:
onHandshake
in interfaceWebSocket<T extends BaseWebsocket>
-
sendMessage
Description copied from interface:WebSocket
Sends 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:
sendMessage
in interfaceWebSocket<T extends BaseWebsocket>
-
sendMessageToOrigin
Description copied from interface:WebSocket
Sends a message to a certain client.The given callable will be evaluated using the security and business unit contexts of the client.
- Specified by:
sendMessageToOrigin
in interfaceWebSocket<T extends BaseWebsocket>
-
sendMessageToUser
- Specified by:
sendMessageToUser
in interfaceWebSocket<T extends BaseWebsocket>
-