T
- the type of data that this event containspublic class ServerSentEvent<T>
extends java.lang.Object
Flux<ServerSentEvent>
or Observable<ServerSentEvent>
is the
reactive equivalent to Spring MVC's SseEmitter
.ServerSentEventHttpMessageWriter
,
Server-Sent Events W3C recommendationModifier and Type | Class and Description |
---|---|
static interface |
ServerSentEvent.Builder<T>
A mutable builder for a
SseEvent . |
private static class |
ServerSentEvent.BuilderImpl<T> |
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
comment |
private T |
data |
private java.lang.String |
event |
private java.lang.String |
id |
private java.time.Duration |
retry |
Modifier | Constructor and Description |
---|---|
private |
ServerSentEvent(java.lang.String id,
java.lang.String event,
T data,
java.time.Duration retry,
java.lang.String comment) |
Modifier and Type | Method and Description |
---|---|
static <T> ServerSentEvent.Builder<T> |
builder()
Return a builder for a
SseEvent . |
static <T> ServerSentEvent.Builder<T> |
builder(T data)
Return a builder for a
SseEvent , populated with the give data. |
java.util.Optional<java.lang.String> |
comment()
Return the comment of this event, if available.
|
java.util.Optional<T> |
data()
Return the
data field of this event, if available. |
java.util.Optional<java.lang.String> |
event()
Return the
event field of this event, if available. |
java.util.Optional<java.lang.String> |
id()
Return the
id field of this event, if available. |
java.util.Optional<java.time.Duration> |
retry()
Return the
retry field of this event, if available. |
java.lang.String |
toString() |
private final java.lang.String id
private final java.lang.String event
private final T data
private final java.time.Duration retry
private final java.lang.String comment
private ServerSentEvent(java.lang.String id, java.lang.String event, T data, java.time.Duration retry, java.lang.String comment)
public static <T> ServerSentEvent.Builder<T> builder()
SseEvent
.T
- the type of data that this event containspublic static <T> ServerSentEvent.Builder<T> builder(T data)
SseEvent
, populated with the give data.T
- the type of data that this event containspublic java.util.Optional<java.lang.String> id()
id
field of this event, if available.public java.util.Optional<java.lang.String> event()
event
field of this event, if available.public java.util.Optional<T> data()
data
field of this event, if available.public java.util.Optional<java.time.Duration> retry()
retry
field of this event, if available.public java.util.Optional<java.lang.String> comment()
public java.lang.String toString()
toString
in class java.lang.Object