Class SseBroadcasterImpl
- All Implemented Interfaces:
SseBroadcaster,AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbroadcast(OutboundSseEvent event) Publish an SSE event to all registeredSseEventSinkinstances.voidclose()Close the broadcaster and all registeredSseEventSinkinstances.voidclose(boolean cascading) Close the broadcaster and release any resources associated with it.voidonClose(Consumer<SseEventSink> onClose) Register a listener, which will be called when this SseBroadcaster closes a given eventSseEventSinkor tries to write to a givenSseEventSinkthat is already closed (either by client closing the connection or by callingSseEventSink.close()on the server side.voidonError(BiConsumer<SseEventSink, Throwable> onError) Register a listener, which will be called when an exception is thrown by a givenSseEventSinkwhen this SseBroadcaster tries to write to it or close it.voidregister(SseEventSink sseEventSink) Register providedSseEventSinkinstance to thisSseBroadcaster.
-
Constructor Details
-
SseBroadcasterImpl
public SseBroadcasterImpl()
-
-
Method Details
-
close
public void close()Description copied from interface:SseBroadcasterClose the broadcaster and all registeredSseEventSinkinstances. Any other resources associated with theSseBroadcastershould be released. This method is equivalent to callingclose(true).Subsequent calls have no effect and are ignored. Once the
SseBroadcasteris closed, invoking any other method on the broadcaster instance would result in anIllegalStateExceptionbeing thrown.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSseBroadcaster
-
close
public void close(boolean cascading) Description copied from interface:SseBroadcasterClose the broadcaster and release any resources associated with it. The closing of registeredSseEventSinkis controlled by thecascadingparameter.Subsequent calls have no effect and are ignored. Once the
SseBroadcasteris closed, invoking any other method on the broadcaster instance would result in anIllegalStateExceptionbeing thrown.- Specified by:
closein interfaceSseBroadcaster- Parameters:
cascading- Boolean value that controls closing of registeredSseEventSinkinstances.
-
onError
Description copied from interface:SseBroadcasterRegister a listener, which will be called when an exception is thrown by a givenSseEventSinkwhen 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
SseBroadcasterimplementation is optimized to efficiently handle small amounts of concurrent listener registrations and removals and large amounts of registered listener notifications.- Specified by:
onErrorin interfaceSseBroadcaster- Parameters:
onError- bi-consumer, taking two parameters:SseEventSink, which is the source of the error and the actualThrowableinstance.
-
onClose
Description copied from interface:SseBroadcasterRegister a listener, which will be called when this SseBroadcaster closes a given eventSseEventSinkor tries to write to a givenSseEventSinkthat is already closed (either by client closing the connection or by callingSseEventSink.close()on the server side.This operation is potentially slow, especially if large number of listeners get registered in the broadcaster. The
SseBroadcasterimplementation is optimized to efficiently handle small amounts of concurrent listener registrations and removals and large amounts of registered listener notifications.- Specified by:
onClosein interfaceSseBroadcaster- Parameters:
onClose- consumer taking single parameter, aSseEventSink, which was closed.
-
register
Description copied from interface:SseBroadcasterRegister providedSseEventSinkinstance to thisSseBroadcaster.- Specified by:
registerin interfaceSseBroadcaster- Parameters:
sseEventSink- to be registered.
-
broadcast
Description copied from interface:SseBroadcasterPublish an SSE event to all registeredSseEventSinkinstances.- Specified by:
broadcastin interfaceSseBroadcaster- Parameters:
event- SSE event to be published.- Returns:
- completion stage that completes when the event has been broadcast to all registered event sinks.
-