Package 

Class SseClient

  • All Implemented Interfaces:
    java.io.Closeable , java.lang.AutoCloseable

    
    public final class SseClient
     implements Closeable
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Context ctx()
      final Boolean terminated() Returns true if close has been called.
      final Unit keepAlive() By blocking SSE connection, you can share client outside the handler to notify it from other sources.
      final Unit onClose(Runnable closeCallback) Add a callback that will be called either when connection is closed through close, or when the emitter is detected as closed.
      Unit close() Close the SseClient
      final Unit sendEvent(Object data) Calls sendEvent with event set to "message"
      final Unit sendEvent(String event, Object data, String id) Attempt to send an event.
      final Unit sendEvent(String event, Object data) Attempt to send an event.
      final Unit sendComment(String comment) Attempt to send a comment.
      • Methods inherited from class java.lang.Object

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

    • Method Detail

      • terminated

         final Boolean terminated()

        Returns true if close has been called. This can either be by user, or by Javalin upon detecting that the emitter is closed.

      • keepAlive

         final Unit keepAlive()

        By blocking SSE connection, you can share client outside the handler to notify it from other sources. Keep in mind that this function is based on top of the Context.future, so you can't use any result function in this scope anymore.

      • onClose

         final Unit onClose(Runnable closeCallback)

        Add a callback that will be called either when connection is closed through close, or when the emitter is detected as closed.

      • sendComment

         final Unit sendComment(String comment)

        Attempt to send a comment. If the emitter fails to emit (remote client has disconnected), the close function will be called instead.