public class SseEvent extends Object
Flux<SseEvent> or Observable<SseEvent> is the
reactive equivalent to Spring MVC's SseEmitter.SseEventHttpMessageWriter,
Server-Sent Events W3C recommendation| Constructor and Description |
|---|
SseEvent()
Create an empty instance.
|
SseEvent(Object data)
Create an instance with the provided
data. |
SseEvent(Object data,
MediaType mediaType)
Create an instance with the provided
data and mediaType. |
| Modifier and Type | Method and Description |
|---|---|
String |
getComment() |
Object |
getData() |
String |
getId() |
MediaType |
getMediaType() |
String |
getName() |
Long |
getReconnectTime() |
void |
setComment(String comment)
Set SSE comment.
|
void |
setData(Object data)
Set
data SSE field. |
void |
setId(String id)
Set the
id SSE field |
void |
setMediaType(MediaType mediaType)
Set the
MediaType used to serialize the data. |
void |
setName(String name)
Set the
event SSE field |
void |
setReconnectTime(Long reconnectTime)
Set the
retry SSE field |
public SseEvent()
public SseEvent(Object data)
data.public void setId(String id)
id SSE fieldpublic String getId()
setId(String)public void setName(String name)
event SSE fieldpublic String getName()
setName(String)public void setData(Object data)
data SSE field. If a multiline String is provided, it will be
turned into multiple data field lines as defined in Server-Sent Events
W3C recommendation.
If no mediaType is defined, default SseEventHttpMessageWriter will:
- Turn single line String to a single data field
- Turn multiline line String to multiple data fields
- Serialize other Object as JSONsetMediaType(MediaType)public Object getData()
setData(Object)public void setMediaType(MediaType mediaType)
MediaType used to serialize the data.
SseEventHttpMessageWriter should be configured with the relevant encoder to be
able to serialize it.public MediaType getMediaType()
setMediaType(MediaType)public void setReconnectTime(Long reconnectTime)
retry SSE fieldpublic Long getReconnectTime()
setReconnectTime(Long)public void setComment(String comment)
SseEventHttpMessageWriter as defined in Server-Sent Events W3C
recommendation.public String getComment()
setComment(String)