Class BaseWebsocket
java.lang.Object
jakarta.websocket.Endpoint
ch.tocco.nice2.web.core.api.websocket.BaseWebsocket
- Direct Known Subclasses:
AbstractWebsocket
,NotificationWebsocketDefinition.NotificationWebsocket
public abstract class BaseWebsocket
extends jakarta.websocket.Endpoint
Base WebSocket implementation that runs the methods
using the
SecurityContext
that was used during the handshake.
It is verified if the nice session that belongs to that SecurityContext
is still active, otherwise the connection will be closed.
One instance of this class will be created per client.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(BaseWebsocketListener listener) void
close()
protected void
doOnClose
(jakarta.websocket.Session session) Called when the connection has been closed (called only once per instance)protected void
protected abstract void
doOnMessage
(jakarta.websocket.Session session, String message) Called when a message has arrived from the client that is bound to this instance.protected void
doOnOpen
(jakarta.websocket.Session session, jakarta.websocket.EndpointConfig config) Called when the connection has been established (called only once per instance)final void
onClose
(jakarta.websocket.Session session, jakarta.websocket.CloseReason closeReason) final void
final void
onOpen
(jakarta.websocket.Session session, jakarta.websocket.EndpointConfig config) void
sendMessage
(Callable<Optional<String>> callable)
-
Constructor Details
-
BaseWebsocket
protected BaseWebsocket(int idleTimeoutSeconds)
-
-
Method Details
-
addListener
-
getUserProperties
-
sendMessage
-
close
public void close() -
onOpen
public final void onOpen(jakarta.websocket.Session session, jakarta.websocket.EndpointConfig config) - Specified by:
onOpen
in classjakarta.websocket.Endpoint
-
onClose
public final void onClose(jakarta.websocket.Session session, jakarta.websocket.CloseReason closeReason) - Overrides:
onClose
in classjakarta.websocket.Endpoint
-
onError
- Overrides:
onError
in classjakarta.websocket.Endpoint
-
doOnMessage
Called when a message has arrived from the client that is bound to this instance. -
doOnOpen
protected void doOnOpen(jakarta.websocket.Session session, jakarta.websocket.EndpointConfig config) Called when the connection has been established (called only once per instance) -
doOnClose
protected void doOnClose(jakarta.websocket.Session session) Called when the connection has been closed (called only once per instance) -
doOnError
-