Package org.glassfish.sse.api
Class ServerSentEventHandler
- java.lang.Object
-
- org.glassfish.sse.api.ServerSentEventHandler
-
public abstract class ServerSentEventHandler extends Object
A handler that handles Server-Sent Events.- Author:
- Jitendra Kotamraju
- See Also:
ServerSentEvent
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ServerSentEventHandler.Status
-
Field Summary
Fields Modifier and Type Field Description protected ServerSentEventConnection
connection
-
Constructor Summary
Constructors Constructor Description ServerSentEventHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onClosed()
Callback to indicate that the client closed the connectionvoid
onConnected(ServerSentEventConnection connection)
A callback to indicate that a client connects to receive Server-Sent Events.ServerSentEventHandler.Status
onConnecting(jakarta.servlet.http.HttpServletRequest request)
A callback to indicate that a client connects to receive Server-Sent Events.
-
-
-
Field Detail
-
connection
protected ServerSentEventConnection connection
-
-
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
-
-