Class ServerSentEventHandler


  • public abstract class ServerSentEventHandler
    extends Object
    A handler that handles Server-Sent Events.
    Author:
    Jitendra Kotamraju
    See Also:
    ServerSentEvent
    • Constructor Detail

      • ServerSentEventHandler

        public ServerSentEventHandler()
    • Method Detail

      • onConnecting

        public ServerSentEventHandler.Status onConnecting​(jakarta.servlet.http.HttpServletRequest request)
        A callback to indicate that a client connects to receive Server-Sent Events. The application has full access to HTTP request and can decide whether to accept the connection or reject it. In SSE, clients will reconnect if the connection is closed, but can be told to stop reconnecting by returning the appropriate status.

        Last-Event-ID may be used in determining the status and it can be got using HttpServletRequest.getHeader("Last-Event-ID")

        Parameters:
        request - connection request
        Returns:
        Status to accept, or don't reconnect etc
      • onConnected

        public void onConnected​(ServerSentEventConnection connection)
        A callback to indicate that a client connects to receive Server-Sent Events. The application has full access to HTTP request and can decide whether to accept the connection or reject it. In SSE, clients will reconnect if the connection is closed, but can be told to stop reconnecting by returning the appropriate status.
        Parameters:
        connection - Server-Sert event connection
      • onClosed

        public void onClosed()
        Callback to indicate that the client closed the connection