Class SocketEndpoint

java.lang.Object
jakarta.websocket.Endpoint
org.omnifaces.cdi.push.SocketEndpoint

public class SocketEndpoint extends Endpoint

This web socket server endpoint handles web socket requests coming from <o:socket>.

Since:
2.3
Author:
Bauke Scholtz
See Also:
  • Field Details

    • URI_TEMPLATE

      public static final String URI_TEMPLATE
      The context-relative URI template where the web socket endpoint should listen on.
      See Also:
  • Constructor Details

    • SocketEndpoint

      public SocketEndpoint()
  • Method Details

    • onOpen

      public void onOpen(Session session, EndpointConfig config)
      Add given web socket session to the SocketSessionManager. If web socket session is not accepted (i.e. the channel identifier is unknown), then immediately close with reason VIOLATED_POLICY (close code 1008).
      Specified by:
      onOpen in class Endpoint
      Parameters:
      session - The opened web socket session.
      config - The endpoint configuration.
    • onError

      public void onError(Session session, Throwable throwable)
      Delegate exception to onClose.
      Overrides:
      onError in class Endpoint
      Parameters:
      session - The errored web socket session.
      throwable - The cause.
    • onClose

      public void onClose(Session session, CloseReason reason)
      Remove given web socket session from the SocketSessionManager. If there is any exception from onError which was not caused by CloseReason.CloseCodes.GOING_AWAY (i.e. "connection reset by peer"), then log it as Level.SEVERE, else as Level.FINE. Before OmniFaces 4.6, the CloseReason.CloseCodes.GOING_AWAY was not logged at all.
      Overrides:
      onClose in class Endpoint
      Parameters:
      session - The closed web socket session.
      reason - The close reason.