Class SseBroadcasterImpl

    • Constructor Detail

      • SseBroadcasterImpl

        public SseBroadcasterImpl()
    • Method Detail

      • close

        public void close()
        Description copied from interface: SseBroadcaster
        Close the broadcaster and all registered SseEventSink instances. Any other resources associated with the SseBroadcaster should be released. This method is equivalent to calling close(true).

        Subsequent calls have no effect and are ignored. Once the SseBroadcaster is closed, invoking any other method on the broadcaster instance would result in an IllegalStateException being thrown.

        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface SseBroadcaster
      • close

        public void close​(boolean cascading)
        Description copied from interface: SseBroadcaster
        Close the broadcaster and release any resources associated with it. The closing of registered SseEventSink is controlled by the cascading parameter.

        Subsequent calls have no effect and are ignored. Once the SseBroadcaster is closed, invoking any other method on the broadcaster instance would result in an IllegalStateException being thrown.

        Specified by:
        close in interface SseBroadcaster
        Parameters:
        cascading - Boolean value that controls closing of registered SseEventSink instances.
      • onError

        public void onError​(BiConsumer<SseEventSink,​Throwable> onError)
        Description copied from interface: SseBroadcaster
        Register a listener, which will be called when an exception is thrown by a given SseEventSink when this SseBroadcaster tries to write to it or close it.

        This operation is potentially slow, especially if large number of listeners get registered in the broadcaster. The SseBroadcaster implementation is optimized to efficiently handle small amounts of concurrent listener registrations and removals and large amounts of registered listener notifications.

        Specified by:
        onError in interface SseBroadcaster
        Parameters:
        onError - bi-consumer, taking two parameters: SseEventSink, which is the source of the error and the actual Throwable instance.
      • onClose

        public void onClose​(Consumer<SseEventSink> onClose)
        Description copied from interface: SseBroadcaster
        Register a listener, which will be called when this SseBroadcaster closes a given event SseEventSink or tries to write to a given SseEventSink that is already closed (either by client closing the connection or by calling SseEventSink.close() on the server side.

        This operation is potentially slow, especially if large number of listeners get registered in the broadcaster. The SseBroadcaster implementation is optimized to efficiently handle small amounts of concurrent listener registrations and removals and large amounts of registered listener notifications.

        Specified by:
        onClose in interface SseBroadcaster
        Parameters:
        onClose - consumer taking single parameter, a SseEventSink, which was closed.