Interface WebSocket<T>

All Known Implementing Classes:
AbstractWebsocketDefinition, AnonymousWebsocket, LoggingWebsocketDefinition, ModelValidationWebsocketDefinition, NotificationWebsocketDefinition, SecureWebsocket, SqlLoggingWebsocketDefinition

public interface WebSocket<T>
  • Method Details

    • webSocketClass

      Class<T> webSocketClass()
      Class of the WebSocket implementation (must extend javax.websocket.Endpoint)
    • createWebSocketInstance

      T createWebSocketInstance()
      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.

    • getPath

      String getPath()
      The relative path where this endpoint should be published. Should start with '/nice2/websocket/' for consistency reasons.
    • onHandshake

      void onHandshake(Map<String,Object> userProperties)
      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.

    • sendMessage

      void sendMessage(Callable<Optional<String>> message)
      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.

    • sendMessageToOrigin

      void sendMessageToOrigin(String originId, Callable<Optional<String>> message)
      Sends a message to a certain client.

      The given callable will be evaluated using the security and business unit contexts of the client.

    • sendMessageToUser

      default void sendMessageToUser(String username, Callable<Optional<String>> message)