Class ServerSentEventGenerator

java.lang.Object
starfederation.datastar.utils.ServerSentEventGenerator
All Implemented Interfaces:
Closeable, AutoCloseable

public class ServerSentEventGenerator extends Object implements Closeable
  • Constructor Details

    • ServerSentEventGenerator

      public ServerSentEventGenerator(AbstractResponseAdapter response)
      Initializes the Server-Sent Event generator.
      Parameters:
      response - the response adapter to send the event to.
  • Method Details

    • send

      public void send(AbstractDatastarEvent event, String id, int retry)
      Sends a Datastar event to the client.
      Parameters:
      event - the event to send
      id - the event id
    • send

      public void send(AbstractDatastarEvent event)
      Sends a Datastar event to the client with a monotonically increasing long ID and default retry duration.
      Parameters:
      event - the event to send
    • send

      public void send(AbstractDatastarEvent event, String id)
      Sends a Datastar event to the client with a specified ID and default retry duration.
      Parameters:
      event - the event to send
      id - the event id
    • send

      public void send(AbstractDatastarEvent event, int retry)
      Sends a Datastar event to the client with a monotonically increasing long ID and specified retry duration.
      Parameters:
      event - the event to send
      retry - the retry duration
    • close

      public void close()
      Closes the writer when finished.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable