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

    Constructors
    Modifier
    Constructor
    Description
    protected
    BaseWebsocket(int idleTimeoutSeconds)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
     
    protected void
    doOnClose(jakarta.websocket.Session session)
    Called when the connection has been closed (called only once per instance)
    protected void
    doOnError(jakarta.websocket.Session session, Throwable cause)
     
    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
    onError(jakarta.websocket.Session session, Throwable cause)
     
    final void
    onOpen(jakarta.websocket.Session session, jakarta.websocket.EndpointConfig config)
     
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BaseWebsocket

      protected BaseWebsocket(int idleTimeoutSeconds)
  • Method Details

    • addListener

      public void addListener(BaseWebsocketListener listener)
    • getUserProperties

      public Map<String,Object> getUserProperties()
    • sendMessage

      public void sendMessage(Callable<Optional<String>> callable)
    • close

      public void close()
    • onOpen

      public final void onOpen(jakarta.websocket.Session session, jakarta.websocket.EndpointConfig config)
      Specified by:
      onOpen in class jakarta.websocket.Endpoint
    • onClose

      public final void onClose(jakarta.websocket.Session session, jakarta.websocket.CloseReason closeReason)
      Overrides:
      onClose in class jakarta.websocket.Endpoint
    • onError

      public final void onError(jakarta.websocket.Session session, Throwable cause)
      Overrides:
      onError in class jakarta.websocket.Endpoint
    • doOnMessage

      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.
    • 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

      protected void doOnError(jakarta.websocket.Session session, Throwable cause)