public class SseBroadcasterImpl extends Object implements SseBroadcaster
Constructor and Description |
---|
SseBroadcasterImpl() |
Modifier and Type | Method and Description |
---|---|
CompletionStage<?> |
broadcast(OutboundSseEvent event)
Publish an SSE event to all registered
SseEventSink instances. |
void |
close()
Close the broadcaster and all registered
SseEventSink instances. |
void |
onClose(Consumer<SseEventSink> onClose)
Register a listener, which will be called when the SSE event output has been closed (either by client closing
the connection or by calling
SseEventSink.close() on the server side. |
void |
onError(BiConsumer<SseEventSink,Throwable> onError)
Register a listener, which will be called when an exception was thrown by a given SSE event output when trying
to write to it or close it.
|
void |
register(SseEventSink sseEventSink)
Register provided
SseEventSink instance to this SseBroadcaster . |
public void close()
SseBroadcaster
SseEventSink
instances.
Any other resources associated with the SseBroadcaster
should be released.
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.
close
in interface AutoCloseable
close
in interface SseBroadcaster
public void onError(BiConsumer<SseEventSink,Throwable> onError)
SseBroadcaster
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.
onError
in interface SseBroadcaster
onError
- bi-consumer, taking two parameters: SseEventSink
, which is the source of the
error and the actual Throwable
instance.public void onClose(Consumer<SseEventSink> onClose)
SseBroadcaster
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.
onClose
in interface SseBroadcaster
onClose
- consumer taking single parameter, a SseEventSink
, which was closed.public void register(SseEventSink sseEventSink)
SseBroadcaster
SseEventSink
instance to this SseBroadcaster
.register
in interface SseBroadcaster
sseEventSink
- to be registered.public CompletionStage<?> broadcast(OutboundSseEvent event)
SseBroadcaster
SseEventSink
instances.broadcast
in interface SseBroadcaster
event
- SSE event to be published.Copyright © 2019 JBoss by Red Hat. All rights reserved.