java.lang.Object
ch.rasc.sse.eventbus.SseEventBus
-
Constructor Summary
ConstructorsConstructorDescriptionSseEventBus(SseEventBusConfigurer configurer, SubscriptionRegistry subscriptionRegistry) -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanUp()intcountSubscribers(String event) Get the number of subscribers to a particular eventorg.springframework.web.servlet.mvc.method.annotation.SseEmittercreateSseEmitter(String clientId) org.springframework.web.servlet.mvc.method.annotation.SseEmittercreateSseEmitter(String clientId, boolean unsubscribe, String... events) org.springframework.web.servlet.mvc.method.annotation.SseEmittercreateSseEmitter(String clientId, Long timeout, boolean unsubscribe, boolean completeAfterMessage, String... events) Creates aSseEmitterand registers the client in the internal database.org.springframework.web.servlet.mvc.method.annotation.SseEmittercreateSseEmitter(String clientId, Long timeout, boolean unsubscribe, String... events) org.springframework.web.servlet.mvc.method.annotation.SseEmittercreateSseEmitter(String clientId, Long timeout, String... events) org.springframework.web.servlet.mvc.method.annotation.SseEmittercreateSseEmitter(String clientId, String... events) Get a collection of all registered clientIdsGet a collection of all registered eventsGet a map that maps events to a collection of clientIdsgetSubscribers(String event) Get all subscribers to a particular eventvoidhandleEvent(SseEvent event) booleanhasSubscribers(String event) Check if a particular event has subscribersvoidregisterClient(String clientId, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) voidregisterClient(String clientId, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter, boolean completeAfterMessage) voidsetDataObjectConverters(List<DataObjectConverter> dataObjectConverters) voidSubscribe to the default event (message)voidvoidsubscribeOnly(String clientId, String event) Subscribe to the event and unsubscribe to all other currently subscribed eventsvoidunregisterClient(String clientId) voidunsubscribe(String clientId, String event) voidunsubscribeFromAllEvents(String clientId, String... keepEvents) Unsubscribe the client from all events except the events provided with the keepEvents parameter.
-
Constructor Details
-
SseEventBus
-
-
Method Details
-
cleanUp
@PreDestroy public void cleanUp() -
createSseEmitter
public org.springframework.web.servlet.mvc.method.annotation.SseEmitter createSseEmitter(String clientId) -
createSseEmitter
-
createSseEmitter
-
createSseEmitter
-
createSseEmitter
-
createSseEmitter
public org.springframework.web.servlet.mvc.method.annotation.SseEmitter createSseEmitter(String clientId, Long timeout, boolean unsubscribe, boolean completeAfterMessage, String... events) Creates aSseEmitterand registers the client in the internal database. Client will be subscribed to the provided events if specified.- Parameters:
clientId- unique client identifiertimeout- timeout value in millisecondsunsubscribe- if true unsubscribes from all events that are not provided with the next parameterevents- events the client wants to subscribe- Returns:
- a new SseEmitter instance
-
registerClient
public void registerClient(String clientId, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) -
registerClient
public void registerClient(String clientId, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter, boolean completeAfterMessage) -
unregisterClient
-
subscribe
Subscribe to the default event (message) -
subscribe
-
subscribeOnly
Subscribe to the event and unsubscribe to all other currently subscribed events -
unsubscribe
-
unsubscribeFromAllEvents
Unsubscribe the client from all events except the events provided with the keepEvents parameter. When keepEvents is null the client unsubscribes from all events -
handleEvent
-
getDataObjectConverters
-
setDataObjectConverters
-
getAllClientIds
Get a collection of all registered clientIds- Returns:
- an unmodifiable set of all registered clientIds
-
getAllEvents
Get a collection of all registered events- Returns:
- an unmodifiable set of all events
-
getAllSubscriptions
Get a map that maps events to a collection of clientIds- Returns:
- map with the event as key, the value is a set of clientIds
-
getSubscribers
Get all subscribers to a particular event- Returns:
- an unmodifiable set of all subscribed clientIds to this event. Empty when nobody is subscribed
-
countSubscribers
Get the number of subscribers to a particular event- Returns:
- the number of clientIds subscribed to this event. 0 when nobody is subscribed
-
hasSubscribers
Check if a particular event has subscribers- Returns:
- true when the event has 1 or more subscribers.
-