Class WebsocketEndpoint

java.lang.Object
jakarta.websocket.Endpoint
com.sun.faces.push.WebsocketEndpoint

public class WebsocketEndpoint extends jakarta.websocket.Endpoint

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

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

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The context-relative URI template where the web socket endpoint should listen on.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onClose(jakarta.websocket.Session session, jakarta.websocket.CloseReason reason)
    Remove given web socket session from the WebsocketSessionManager.
    void
    onError(jakarta.websocket.Session session, Throwable throwable)
    Delegate exception to onClose.
    void
    onOpen(jakarta.websocket.Session session, jakarta.websocket.EndpointConfig config)
    Add given web socket session to the WebocketSessionManager.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

    • WebsocketEndpoint

      public WebsocketEndpoint()
  • Method Details

    • onOpen

      public void onOpen(jakarta.websocket.Session session, jakarta.websocket.EndpointConfig config)
      Add given web socket session to the WebocketSessionManager. 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 jakarta.websocket.Endpoint
      Parameters:
      session - The opened web socket session.
      config - The endpoint configuration.
    • onError

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

      public void onClose(jakarta.websocket.Session session, jakarta.websocket.CloseReason reason)
      Remove given web socket session from the WebsocketSessionManager. If there is any exception from onError which was not caused by GOING_AWAY, then log it. Tomcat <= 8.0.30 is known to throw an unnecessary exception when client abruptly disconnects, see also issue 57489.
      Overrides:
      onClose in class jakarta.websocket.Endpoint
      Parameters:
      session - The closed web socket session.
      reason - The close reason.