java.lang.Object
io.jooby.ServerSentMessage
Server-Sent message.
- Since:
- 2.5.0
- Author:
- edgar
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetData()
The data field for the message.getEvent()
A string identifying the type of event described.getId()
The event ID to set the EventSource object's last event ID value.getRetry()
The reconnection time to use when attempting to send the event.Set event type.Set The event ID to set the EventSource object's last event ID value.Set retry option.byte[]
toByteArray
(Context ctx) Encode message as event source stream format.
-
Constructor Details
-
ServerSentMessage
Creates a new message.- Parameters:
data
- Data. Must not benull
.
-
-
Method Details
-
getId
The event ID to set the EventSource object's last event ID value.- Returns:
- The event ID to set the EventSource object's last event ID value.
-
setId
Set The event ID to set the EventSource object's last event ID value.- Parameters:
id
- Event ID. Converted to String.- Returns:
- This message.
-
getEvent
A string identifying the type of event described. If this is specified, an event will be dispatched on the browser to the listener for the specified event name; the website source code should use addEventListener() to listen for named events. The onmessage handler is called if no event name is specified for a message.- Returns:
- Event type.
-
setEvent
Set event type.- Parameters:
event
- Event type.- Returns:
- This message.
-
getData
The data field for the message. When the EventSource receives multiple consecutive lines that begin with data:, it will concatenate them, inserting a newline character between each one. Trailing newlines are removed.- Returns:
- Data.
-
getRetry
The reconnection time to use when attempting to send the event. This must be an integer, specifying the reconnection time in milliseconds. If a non-integer value is specified, the field is ignored.- Returns:
- Retry option.
-
setRetry
Set retry option.- Parameters:
retry
- Retry option.- Returns:
- This message.
-
toByteArray
Encode message as event source stream format.- Parameters:
ctx
- Web context. To encode complex objects.- Returns:
- Encoded data.
-