Package io.micronaut.http.sse
Interface Event<T>
-
- Type Parameters:
T
- The event type
public interface Event<T>
Represents a Server Sent Event. See https://www.w3.org/TR/2011/WD-eventsource-20111020/.- Since:
- 1.0
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Event<T>
comment(java.lang.String comment)
Sets the event comment.java.lang.String
getComment()
T
getData()
java.lang.String
getId()
java.lang.String
getName()
java.time.Duration
getRetry()
Event<T>
id(java.lang.String id)
Sets the id.Event<T>
name(java.lang.String name)
Sets the event name.static <ET> Event<ET>
of(ET data)
Constructs a new event for the given data.static <ET> Event<ET>
of(Event event, ET data)
Constructs a new event for the given data.Event<T>
retry(java.time.Duration duration)
Sets the retry duration.
-
-
-
Field Detail
-
ID
static final java.lang.String ID
The id parameter.- See Also:
- Constant Field Values
-
EVENT
static final java.lang.String EVENT
The event parameter.- See Also:
- Constant Field Values
-
DATA
static final java.lang.String DATA
The data parameter.- See Also:
- Constant Field Values
-
RETRY
static final java.lang.String RETRY
The retry parameter.- See Also:
- Constant Field Values
-
-
Method Detail
-
getData
T getData()
- Returns:
- The data object to write
-
getId
java.lang.String getId()
- Returns:
- The ID of the event, or null if there is no ID
-
getName
java.lang.String getName()
- Returns:
- The name of the event
-
getComment
java.lang.String getComment()
- Returns:
- A comment for the event, or null if there is no comment
-
getRetry
java.time.Duration getRetry()
- Returns:
- The duration to retry
-
retry
Event<T> retry(@Nullable java.time.Duration duration)
Sets the retry duration.- Parameters:
duration
- The duration- Returns:
- The event
-
id
Event<T> id(@Nullable java.lang.String id)
Sets the id.- Parameters:
id
- The id to set- Returns:
- The event
-
name
Event<T> name(@Nullable java.lang.String name)
Sets the event name.- Parameters:
name
- The event name- Returns:
- The event
-
comment
Event<T> comment(@Nullable java.lang.String comment)
Sets the event comment.- Parameters:
comment
- The Event comment- Returns:
- The event
-
of
static <ET> Event<ET> of(ET data)
Constructs a new event for the given data.- Type Parameters:
ET
- The data type- Parameters:
data
- The data- Returns:
- The event instance
-
-