Class SseResponseSupport
java.lang.Object
org.apache.juneau.rest.server.sse.SseResponseSupport
- All Implemented Interfaces:
AutoCloseable
Fluent SSE response helper.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Sends a heartbeat/comment line.flush()Flushes pending output.Starts periodic heartbeat comments.Sends an SSE event from name+data values.Sends an SSE event.sendFrom(SseSubscription subscription) Drains a subscription until disconnect or interruption.
-
Constructor Details
-
SseResponseSupport
Constructor.- Parameters:
response- The REST response. Must not benull .- Throws:
IOException- If the writer could not be created.
-
-
Method Details
-
heartbeat
Starts periodic heartbeat comments.- Parameters:
interval- The heartbeat interval.- Returns:
- This object.
-
sendEvent
Sends an SSE event.- Parameters:
event- The event.- Returns:
- This object.
- Throws:
IOException- If an I/O error occurred.
-
sendEvent
Sends an SSE event from name+data values.- Parameters:
name- The event name. Can benull (dispatches as the default event type).data- The event data. Can benull (no data lines emitted).- Returns:
- This object.
- Throws:
IOException- If an I/O error occurred.
-
comment
Sends a heartbeat/comment line.- Parameters:
value- The comment value. Can benull (treated as an empty comment).- Returns:
- This object.
- Throws:
IOException- If an I/O error occurred.
-
flush
Flushes pending output.- Returns:
- This object.
- Throws:
IOException- If an I/O error occurred.
-
sendFrom
Drains a subscription until disconnect or interruption.- Parameters:
subscription- The subscription. Must not benull .- Returns:
- This object.
- Throws:
IOException- If an I/O error occurred.
-
close
- Specified by:
closein interfaceAutoCloseable
-