Interface SseClient

All Superinterfaces:
AutoCloseable

@Experimental @NoImplement @MinMuleVersion("4.10.0") public interface SseClient extends AutoCloseable
Server-side abstraction of a connected client.
Since:
0.12.0
  • Method Details

    • sendEvent

      void sendEvent(String name, String data, String id, Long retryDelay) throws IOException
      Sends an event to the client represented by this interface.
      Parameters:
      name - the event name (topic).
      data - the data as string.
      id - event id (used to resume an event stream on reconnection).
      retryDelay - new retry delay, in milliseconds.
      Throws:
      IOException
    • sendEvent

      default void sendEvent(String name, String data, String id) throws IOException
      Equivalent to call sendEvent(name, data, id, null);
      Parameters:
      name - the event name (topic).
      data - the data as string.
      id - event id (used to resume an event stream on reconnection).
      Throws:
      IOException
    • sendEvent

      default void sendEvent(String name, String data) throws IOException
      Equivalent to call sendEvent(name, data, null, null);
      Parameters:
      name - the event name (topic).
      data - the data as string.
      Throws:
      IOException
    • sendEvent

      default void sendEvent(String data) throws IOException
      Equivalent to call sendEvent("message", data, null, null);

      Note: If you want to send a message without a topic, you can call sendEvent(null, data);

      Parameters:
      data - the data as string.
      Throws:
      IOException
    • sendComment

      void sendComment(String comment)
      Sends a comment.
      Parameters:
      comment - the comment.
    • onClose

      void onClose(Consumer<Throwable> callback)
      The callback will be called when the client closes its connection or there is an error sending the response.
      Parameters:
      callback - to be called in that situation.
    • getClientId

      String getClientId()
      Returns:
      unique identifier of this client.
    • getRemoteAddress

      InetSocketAddress getRemoteAddress()
      Returns:
      the address of the remote client.
    • close

      void close() throws IOException
      Closes the connection.
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException