Class ServerSentEvent

java.lang.Object
com.soklet.ServerSentEvent

@ThreadSafe public class ServerSentEvent extends Object
Encapsulates a Server-Sent Event payload that can be sent across the wire to a client.

For example:

 ServerSentEvent serverSentEvent = ServerSentEvent.withEvent("example")
  .data("""
    {
      "testing": 123,
      "value": "abc"
    }
    """)
  .id(UUID.randomUUID().toString())
  .retry(Duration.ofSeconds(5))
  .build();

To acquire an event suitable for heartbeats, use the forHeartbeat() factory method.

See https://www.soklet.com/docs/server-sent-events for detailed documentation.

Formal specification is available at https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events.

Author:
Mark Allen