Package org.glassfish.sse.api
Class ServerSentEventConnection
- java.lang.Object
-
- org.glassfish.sse.api.ServerSentEventConnection
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public abstract class ServerSentEventConnection extends Object implements Closeable
Represents a Server-Sent Event connection for sending push notifications- Author:
- Jitendra Kotamraju
-
-
Constructor Summary
Constructors Constructor Description ServerSentEventConnection()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidclose()Closes the connectionStringgetLastEventID()Event source's last event ID.abstract jakarta.servlet.http.HttpServletRequestgetRequest()Servlet request for Server-Sent Event connectionabstract voidsendMessage(String eventData)Sends the Server-Sent event to clientabstract voidsendMessage(ServerSentEventData eventData)Sends the Server-Sent event to client
-
-
-
Method Detail
-
getRequest
public abstract jakarta.servlet.http.HttpServletRequest getRequest()
Servlet request for Server-Sent Event connection- Returns:
- servlet request
-
getLastEventID
public String getLastEventID()
Event source's last event ID.- Returns:
- null if there is no HTTP header in the request otherwise, last event ID
-
sendMessage
public abstract void sendMessage(String eventData) throws IOException
Sends the Server-Sent event to client- Parameters:
eventData- Server-Sent event data- Throws:
IOException- when there is an error in sendingIllegalStateException- when called after calling close method- See Also:
ServerSentEventData
-
sendMessage
public abstract void sendMessage(ServerSentEventData eventData) throws IOException
Sends the Server-Sent event to client- Parameters:
eventData- Server-Sent event data- Throws:
IOException- when there is an error in sendingIllegalStateException- when called after calling close method- See Also:
ServerSentEventData
-
close
public abstract void close()
Closes the connection- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-