Class ServerSentEvent

  • Direct Known Subclasses:
    ServerSentEvent

    public abstract class ServerSentEvent
    extends java.lang.Object
    Representation of a server-sent event. According to the specification, an empty data field designates an event which is to be ignored which is useful for heartbeats.
    • Constructor Summary

      Constructors 
      Constructor Description
      ServerSentEvent()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static ServerSentEvent create​(java.lang.String data)
      Creates a [[ServerSentEvent]].
      static ServerSentEvent create​(java.lang.String data, int retry)
      Creates a [[ServerSentEvent]].
      static ServerSentEvent create​(java.lang.String data, java.lang.String type)
      Creates a [[ServerSentEvent]].
      static ServerSentEvent create​(java.lang.String data, java.lang.String type, java.lang.String id)
      Creates a [[ServerSentEvent]].
      static ServerSentEvent create​(java.lang.String data, java.util.Optional<java.lang.String> type, java.util.Optional<java.lang.String> id, java.util.OptionalInt retry)
      Creates a [[ServerSentEvent]].
      abstract java.lang.String getData()
      Data, may span multiple lines.
      abstract java.util.Optional<java.lang.String> getEventType()
      Optional type, must not contain \n or \r.
      abstract java.util.Optional<java.lang.String> getId()
      Optional id, must not contain \n or \r.
      abstract java.util.OptionalInt getRetry()
      Optional reconnection delay in milliseconds.
      static ServerSentEvent heartbeat()
      Provides a [[ServerSentEvent]] with empty data which can be used as a heartbeat
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ServerSentEvent

        public ServerSentEvent()
    • Method Detail

      • heartbeat

        public static ServerSentEvent heartbeat()
        Provides a [[ServerSentEvent]] with empty data which can be used as a heartbeat
      • create

        public static ServerSentEvent create​(java.lang.String data)
        Creates a [[ServerSentEvent]].
        Parameters:
        data - data, may be empty or span multiple lines
      • create

        public static ServerSentEvent create​(java.lang.String data,
                                             java.lang.String type)
        Creates a [[ServerSentEvent]].
        Parameters:
        data - data, may span multiple lines
        type - type, must not contain \n or \r
      • create

        public static ServerSentEvent create​(java.lang.String data,
                                             java.lang.String type,
                                             java.lang.String id)
        Creates a [[ServerSentEvent]].
        Parameters:
        data - data, may span multiple lines
        type - type, must not contain \n or \r
        id - id, must not contain \n or \r
      • create

        public static ServerSentEvent create​(java.lang.String data,
                                             int retry)
        Creates a [[ServerSentEvent]].
        Parameters:
        data - data, may span multiple lines
        retry - reconnection delay in milliseconds
      • create

        public static ServerSentEvent create​(java.lang.String data,
                                             java.util.Optional<java.lang.String> type,
                                             java.util.Optional<java.lang.String> id,
                                             java.util.OptionalInt retry)
        Creates a [[ServerSentEvent]].
        Parameters:
        data - data, may span multiple lines
        type - optional type, must not contain \n or \r
        id - optional id, must not contain \n or \r
        retry - optional reconnection delay in milliseconds
      • getData

        public abstract java.lang.String getData()
        Data, may span multiple lines.
      • getEventType

        public abstract java.util.Optional<java.lang.String> getEventType()
        Optional type, must not contain \n or \r.
      • getId

        public abstract java.util.Optional<java.lang.String> getId()
        Optional id, must not contain \n or \r.
      • getRetry

        public abstract java.util.OptionalInt getRetry()
        Optional reconnection delay in milliseconds.