Class SseEventSourceImpl

java.lang.Object
org.jboss.resteasy.plugins.providers.sse.client.SseEventSourceImpl
All Implemented Interfaces:
SseEventSource, AutoCloseable

public class SseEventSourceImpl extends Object implements SseEventSource
  • Field Details

  • Constructor Details

    • SseEventSourceImpl

      public SseEventSourceImpl(WebTarget target)
    • SseEventSourceImpl

      public SseEventSourceImpl(WebTarget target, boolean open)
  • Method Details

    • open

      public void open()
      Description copied from interface: SseEventSource
      Open the connection to the supplied SSE underlying web target and start processing incoming events.
      Specified by:
      open in interface SseEventSource
    • open

      public void open(String lastEventId)
    • open

      public void open(String lastEventId, String verb, Entity<?> entity, MediaType... mediaTypes)
    • isOpen

      public boolean isOpen()
      Description copied from interface: SseEventSource
      Check if this event source instance has already been opened.
      Specified by:
      isOpen in interface SseEventSource
      Returns:
      true if this event source is open, false otherwise.
    • register

      public void register(Consumer<InboundSseEvent> onEvent)
      Description copied from interface: SseEventSource
      Register a InboundSseEvent consumer.

      Given consumer is invoked once per each received event.

      Specified by:
      register in interface SseEventSource
      Parameters:
      onEvent - event consumer.
    • register

      public void register(Consumer<InboundSseEvent> onEvent, Consumer<Throwable> onError)
      Description copied from interface: SseEventSource
      Register InboundSseEvent and Throwable consumers.

      Event consumer is invoked once per each received event, Throwable consumer is invoked invoked upon a unrecoverable error encountered by a SseEventSource.

      Specified by:
      register in interface SseEventSource
      Parameters:
      onEvent - event consumer.
      onError - error consumer.
    • register

      public void register(Consumer<InboundSseEvent> onEvent, Consumer<Throwable> onError, Runnable onComplete)
      Description copied from interface: SseEventSource
      Register InboundSseEvent and Throwable consumers and onComplete callback.

      Event consumer is invoked once per each received event, Throwable consumer is invoked invoked upon a unrecoverable error encountered by a SseEventSource, onComplete callback is invoked after a successful connection and when there are no further events to be received. Note that the onComplete callback will not be invoked if the onError callback has been invoked.

      Specified by:
      register in interface SseEventSource
      Parameters:
      onEvent - event consumer.
      onError - error consumer.
      onComplete - onComplete handler.
    • close

      public boolean close(long timeout, TimeUnit unit)
      Description copied from interface: SseEventSource
      Close this event source and wait for the internal event processing task to complete for up to the specified amount of wait time.

      The method blocks until the event processing task has completed execution after a shutdown request, or until the timeout occurs, or the current thread is interrupted, whichever happens first.

      In case the waiting for the event processing task has been interrupted, this method restores the interrupt flag on the thread before returning false.

      Specified by:
      close in interface SseEventSource
      Parameters:
      timeout - the maximum time to wait.
      unit - the time unit of the timeout argument.
      Returns:
      true if this executor terminated and false if the timeout elapsed before termination or the termination was interrupted.