org.springframework.http.codec

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 java.lang.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:
    ServerSentEventHttpMessageWriter, Server-Sent Events W3C recommendation
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static interface  ServerSentEvent.Builder<T>
      A mutable builder for a SseEvent.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      static <T> ServerSentEvent.Builder<T> builder()
      Return a builder for a SseEvent.
      static <T> ServerSentEvent.Builder<T> builder(T data)
      Return a builder for a SseEvent, populated with the give data.
      java.lang.String comment()
      Return the comment of this event, if available.
      T data()
      Return the data field of this event, if available.
      java.lang.String event()
      Return the event field of this event, if available.
      java.lang.String id()
      Return the id field of this event, if available.
      java.time.Duration retry()
      Return the retry field of this event, if available.
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • id

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

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

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

        @Nullable
        public java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • builder

        public static <T> ServerSentEvent.Builder<T> builder()
        Return a builder for a SseEvent.
        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 SseEvent, populated with the give data.
        Type Parameters:
        T - the type of data that this event contains
        Returns:
        the builder