Package org.glassfish.jersey.media.sse
Class InboundEvent
java.lang.Object
org.glassfish.jersey.media.sse.InboundEvent
- All Implemented Interfaces:
InboundSseEvent,SseEvent
Inbound event.
- Author:
- Pavel Bucek, Marek Potociar
-
Field Summary
Fields inherited from interface jakarta.ws.rs.sse.SseEvent
RECONNECT_NOT_SET -
Method Summary
Modifier and TypeMethodDescriptionGet a comment string that accompanies the event.getId()Get event identifier.getName()Get event name.byte[]Get the raw event data bytes.longGet new connection retry time in milliseconds the event receiver should wait before attempting to reconnect after a connection to the SSE event source is lost.booleanisEmpty()Check if the event is empty (i.e.booleanCheck if the connection retry time has been set in the event.readData()Get the original event data stringString.<T> TreadData(GenericType<T> type) Read event data as a given generic type.<T> TreadData(GenericType<T> type, MediaType mediaType) Read event data as a given generic type.<T> TRead event data as a given Java type.<T> TRead event data as a given Java type.toString()
-
Method Details
-
getName
Get event name.Contains value of SSE
"event"field. This field is optional. Method may returnnull, if the event name is not specified. -
getId
Get event identifier.Contains value of SSE
"id"field. This field is optional. Method may returnnull, if the event identifier is not specified. -
getComment
Get a comment string that accompanies the event.Contains value of the comment associated with SSE event. This field is optional. Method may return
null, if the event comment is not specified.- Specified by:
getCommentin interfaceSseEvent- Returns:
- comment associated with the event.
- Since:
- 2.21
-
getReconnectDelay
public long getReconnectDelay()Get new connection retry time in milliseconds the event receiver should wait before attempting to reconnect after a connection to the SSE event source is lost.Contains value of SSE
"retry"field. This field is optional. Method returnsSseFeature.RECONNECT_NOT_SETif no value has been set.- 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 new reconnection delay has been set in the event,falseotherwise.- Since:
- 2.3
-
isEmpty
public boolean isEmpty()Check if the event is empty (i.e. does not contain any data).- Specified by:
isEmptyin interfaceInboundSseEvent- Returns:
trueif current instance does not contain any data,falseotherwise.
-
readData
Get the original event data stringString.- Specified by:
readDatain interfaceInboundSseEvent- Returns:
- event data de-serialized into a string.
- Throws:
ProcessingException- when provided type can't be read. The thrown exception wraps the original cause.- Since:
- 2.3
-
readData
Read event data as a given Java type.- Specified by:
readDatain interfaceInboundSseEvent- Parameters:
type- Java type to be used for event data de-serialization.- Returns:
- event data de-serialized as an instance of a given type.
- Throws:
ProcessingException- when provided type can't be read. The thrown exception wraps the original cause.- Since:
- 2.3
-
readData
Read event data as a given generic type.- Specified by:
readDatain interfaceInboundSseEvent- Parameters:
type- generic type to be used for event data de-serialization.- Returns:
- event data de-serialized as an instance of a given type.
- Throws:
ProcessingException- when provided type can't be read. The thrown exception wraps the original cause.- Since:
- 2.3
-
readData
Read event data as a given Java type.- Specified by:
readDatain interfaceInboundSseEvent- Parameters:
messageType- Java type to be used for event data de-serialization.mediaType-media typeto be used for event data de-serialization.- Returns:
- event data de-serialized as an instance of a given type.
- Throws:
ProcessingException- when provided type can't be read. The thrown exception wraps the original cause.- Since:
- 2.3
-
readData
Read event data as a given generic type.- Specified by:
readDatain interfaceInboundSseEvent- Parameters:
type- generic type to be used for event data de-serialization.mediaType-media typeto be used for event data de-serialization.- Returns:
- event data de-serialized as an instance of a given type.
- Throws:
ProcessingException- when provided type can't be read. The thrown exception wraps the original cause.- Since:
- 2.3
-
getRawData
public byte[] getRawData()Get the raw event data bytes.- Returns:
- raw event data bytes. The returned byte array may be empty if the event does not contain any data.
-
toString
-