Class SseEvent

java.lang.Object
io.helidon.http.sse.SseEvent

public class SseEvent extends Object
An SSE event.
  • Field Details

    • NO_DATA

      public static final Object NO_DATA
      Value returned by data() when no data has been set.
  • Method Details

    • create

      public static SseEvent create(Object data)
      Creates a new SSE event with data.
      Parameters:
      data - data for the event
      Returns:
      newly created SSE event
    • create

      public static SseEvent create(Object data, MediaType mediaType)
      Creates a new SSE event with data and media type.
      Parameters:
      data - data for the event
      mediaType - media type for this event if not text/plain
      Returns:
      newly created SSE event
    • builder

      public static SseEvent.Builder builder()
      Creates builder for this class.
      Returns:
      new builder
    • data

      public Object data()
      Get data for this event.
      Returns:
      the data or NO_DATA
    • data

      public <T> T data(Class<T> clazz, MediaType mediaType)
      Get data for this event as type T. Uses media support to convert event data to type T.
      Type Parameters:
      T - the converted type
      Parameters:
      clazz - the class
      mediaType - media type of event data
      Returns:
      the converted data
    • data

      public <T> T data(Class<T> clazz)
      Get data for this event as type T. Uses media support to convert event data to type T.
      Type Parameters:
      T - the converted type
      Parameters:
      clazz - the class
      Returns:
      the converted data
    • mediaType

      public Optional<MediaType> mediaType()
      Get optional media type for this event. If the media type is specified here, it will be used for serialization purposes.
      Returns:
      the media type
    • mediaContext

      public Optional<MediaContext> mediaContext()
      Get optional media context for this event. If the media type is specified here, it will be used for deserialization purposes.
      Returns:
      the media type
      See Also:
    • id

      public Optional<String> id()
      Get optional ID for this event.
      Returns:
      optional ID
    • name

      public Optional<String> name()
      Get optional name for this event.
      Returns:
      optional name
    • comment

      public Optional<String> comment()
      Get optional comment for this event.
      Returns:
      optional comment
    • reconnectMillis

      public Optional<Duration> reconnectMillis()
      Get optional reconnect for this event.
      Returns:
      optional reconnect