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
  • Method Details

    • getName

      public String getName()
      Get event name.

      This field is optional. If specified, will be send as a value of the SSE "event" field.

      Specified by:
      getName in interface SseEvent
      Returns:
      event name, or null if not set.
    • 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.

      Specified by:
      getId in interface SseEvent
      Returns:
      event identifier, or null if not set.
    • 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:
      getReconnectDelay in interface SseEvent
      Returns:
      reconnection delay in milliseconds or SseFeature.RECONNECT_NOT_SET if 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:
      isReconnectDelaySet in interface SseEvent
      Returns:
      true if reconnection delay in milliseconds has been set in the event, false otherwise.
      Since:
      2.3
    • getType

      public Class<?> getType()
      Get data type.

      This information is used to select a proper MessageBodyWriter to be used for serializing the event data.

      Specified by:
      getType in interface OutboundSseEvent
      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 MessageBodyWriter to be used for serializing the event data.

      Specified by:
      getGenericType in interface OutboundSseEvent
      Returns:
      generic data type. May return null, if the event does not contain any data.
      Since:
      2.3
    • getMediaType

      public MediaType getMediaType()
      Get media type of the event data.

      This information is used to a select proper MessageBodyWriter to be used for serializing the event data.

      Specified by:
      getMediaType in interface OutboundSseEvent
      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:
      getComment in interface SseEvent
      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 available MessageBodyWriter that is selected based on the event type, getGenericType() generic type} and getMediaType() media type}.

      Specified by:
      getData in interface OutboundSseEvent
      Returns:
      event data. May return null, if the event does not contain any data.