Package org.apache.juneau.marshall.sse
Class SseEvent
java.lang.Object
org.apache.juneau.marshall.sse.SseEvent
Represents a single Server-Sent Event
(SSE) frame on the wire.
Each event maps to a sequence of
event: progress data: {"step":4,"total":10} id: 42 retry: 5000
The payload field data is a pre-serialized String — the SSE
serializer does not compose with a delegate marshaller. Callers that need a typed payload should
serialize it themselves (e.g. via Json.of(x))
and assign the resulting string to setData(...). The serializer will
split that string on \n into multiple
Example: build and serialize an event:
SseEvent
Notes:
- This class is not thread safe.
See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault event-type name dispatched by the WHATWGEventSource when noevent: field is present. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleangetData()Returns the data payload (pre-serialized string).getEvent()Returns the event-type name.getId()Returns the last-event-id value.getRetry()Returns the reconnect-delay hint in milliseconds.inthashCode()Sets the data payload.Sets the event-type name.Sets the last-event-id value.Sets the reconnect-delay hint in milliseconds.toString()
-
Field Details
-
DEFAULT_EVENT
Default event-type name dispatched by the WHATWGEventSource when noevent: field is present.- See Also:
-
-
Constructor Details
-
Method Details
-
getEvent
Returns the event-type name.- Returns:
- The event-type name, or
null if not set.
-
setEvent
Sets the event-type name.- Parameters:
value- The event-type name. Can benull to unset.- Returns:
- This object.
-
getData
Returns the data payload (pre-serialized string).- Returns:
- The data payload, or
null if not set.
-
setData
Sets the data payload.- Parameters:
value- The pre-serialized payload string. Can benull to unset.- Returns:
- This object.
-
getId
Returns the last-event-id value.- Returns:
- The id, or
null if not set.
-
setId
Sets the last-event-id value.- Parameters:
value- The id. Can benull to unset.- Returns:
- This object.
-
getRetry
Returns the reconnect-delay hint in milliseconds.- Returns:
- The retry value, or
null if not set.
-
setRetry
Sets the reconnect-delay hint in milliseconds.- Parameters:
value- The retry value. Can benull to unset.- Returns:
- This object.
-
equals
-
hashCode
-
toString
-