Class OutboundEvent
- java.lang.Object
-
- org.glassfish.jersey.media.sse.OutboundEvent
-
- All Implemented Interfaces:
OutboundSseEvent,SseEvent
public final class OutboundEvent extends Object implements OutboundSseEvent
Representation of a single outbound SSE event.- Author:
- Pavel Bucek, Marek Potociar
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOutboundEvent.BuilderUsed for creatingOutboundEventinstances.
-
Field Summary
-
Fields inherited from interface jakarta.ws.rs.sse.SseEvent
RECONNECT_NOT_SET
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetComment()Get a comment string that accompanies the event.ObjectgetData()Get event data.TypegetGenericType()Get generic data type.StringgetId()Get event identifier.MediaTypegetMediaType()Getmedia typeof the event data.StringgetName()Get event name.longgetReconnectDelay()Get connection retry time in milliseconds the event receiver should wait before attempting to reconnect after a connection to the SSE source is lost.Class<?>getType()Get data type.booleanisReconnectDelaySet()Check if the connection retry time has been set in the event.
-
-
-
Method Detail
-
getName
public String getName()
Get event name.This field is optional. If specified, will be send as a value of the SSE
"event"field.
-
getId
public String getId()
Get event identifier.This field is optional. If specified, the value is send as a value of the SSE
"id"field.
-
getReconnectDelay
public long getReconnectDelay()
Get connection retry time in milliseconds the event receiver should wait before attempting to reconnect after a connection to the SSE source is lost.This field is optional. If specified, the value is send as a value of the SSE
"retry"field.- Specified by:
getReconnectDelayin interfaceSseEvent- Returns:
- reconnection delay in milliseconds or
SseFeature.RECONNECT_NOT_SETif no value has been set. - Since:
- 2.3
-
isReconnectDelaySet
public boolean isReconnectDelaySet()
Check if the connection retry time has been set in the event.- Specified by:
isReconnectDelaySetin interfaceSseEvent- Returns:
trueif reconnection delay in milliseconds has been set in the event,falseotherwise.- Since:
- 2.3
-
getType
public Class<?> getType()
Get data type.This information is used to select a proper
MessageBodyWriterto be used for serializing theevent data.- Specified by:
getTypein interfaceOutboundSseEvent- Returns:
- data type. May return
null, if the event does not contain any data.
-
getGenericType
public Type getGenericType()
Get generic data type.This information is used to select a proper
MessageBodyWriterto be used for serializing theevent data.- Specified by:
getGenericTypein interfaceOutboundSseEvent- Returns:
- generic data type. May return
null, if the event does not contain any data. - Since:
- 2.3
-
getMediaType
public MediaType getMediaType()
Getmedia typeof the event data.This information is used to a select proper
MessageBodyWriterto be used for serializing theevent data.- Specified by:
getMediaTypein interfaceOutboundSseEvent- Returns:
- data
MediaType.
-
getComment
public String getComment()
Get a comment string that accompanies the event.If specified, the comment value is sent with the event as one or more SSE comment lines (depending on line breaks in the actual data string), before any actual event data are serialized. If the event instance does not contain any data, a separate "event" that contains only the comment will be sent. Comment information is optional, provided the event data are set.
- Specified by:
getCommentin interfaceSseEvent- Returns:
- comment associated with the event.
-
getData
public Object getData()
Get event data.The event data, if specified, are serialized and sent as one or more SSE event
"data"fields (depending on the line breaks in the actual serialized data content). The data are serialized using an availableMessageBodyWriterthat is selected based on the eventtype,getGenericType()generic type} andgetMediaType()media type}.- Specified by:
getDatain interfaceOutboundSseEvent- Returns:
- event data. May return
null, if the event does not contain any data.
-
-