Class ServerSentEvent<T>

java.lang.Object
org.springframework.http.codec.ServerSentEvent<T>
Type Parameters:
T - the type of data that this event contains

public final class ServerSentEvent<T> extends Object
Representation for a Server-Sent Event for use with Spring's reactive Web support. Flux<ServerSentEvent> or Observable<ServerSentEvent> is the reactive equivalent to Spring MVC's SseEmitter.
Since:
5.0
Author:
Sebastien Deleuze, Arjen Poutsma
See Also:
  • Method Details

    • id

      @Nullable public String id()
      Return the id field of this event, if available.
    • event

      @Nullable public String event()
      Return the event field of this event, if available.
    • retry

      @Nullable public Duration retry()
      Return the retry field of this event, if available.
    • comment

      @Nullable public String comment()
      Return the comment of this event, if available.
    • data

      @Nullable public T data()
      Return the data field of this event, if available.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • builder

      public static <T> ServerSentEvent.Builder<T> builder()
      Return a builder for a ServerSentEvent.
      Type Parameters:
      T - the type of data that this event contains
      Returns:
      the builder
    • builder

      public static <T> ServerSentEvent.Builder<T> builder(T data)
      Return a builder for a ServerSentEvent, populated with the given data.
      Type Parameters:
      T - the type of data that this event contains
      Returns:
      the builder