public class SseEventBus extends Object
| Constructor and Description |
|---|
SseEventBus(SseEventBusConfigurer configurer,
SubscriptionRegistry subscriptionRegistry) |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanUp() |
int |
countSubscribers(String event)
Get the number of subscribers to a particular event
|
org.springframework.web.servlet.mvc.method.annotation.SseEmitter |
createSseEmitter(String clientId) |
org.springframework.web.servlet.mvc.method.annotation.SseEmitter |
createSseEmitter(String clientId,
boolean unsubscribe,
String... events) |
org.springframework.web.servlet.mvc.method.annotation.SseEmitter |
createSseEmitter(String clientId,
Long timeout,
boolean unsubscribe,
boolean completeAfterMessage,
String... events)
Creates a
SseEmitter and registers the client in the internal database. |
org.springframework.web.servlet.mvc.method.annotation.SseEmitter |
createSseEmitter(String clientId,
Long timeout,
boolean unsubscribe,
String... events) |
org.springframework.web.servlet.mvc.method.annotation.SseEmitter |
createSseEmitter(String clientId,
Long timeout,
String... events) |
org.springframework.web.servlet.mvc.method.annotation.SseEmitter |
createSseEmitter(String clientId,
String... events) |
Set<String> |
getAllClientIds()
Get a collection of all registered clientIds
|
Set<String> |
getAllEvents()
Get a collection of all registered events
|
Map<String,Set<String>> |
getAllSubscriptions()
Get a map that maps events to a collection of clientIds
|
List<DataObjectConverter> |
getDataObjectConverters() |
Set<String> |
getSubscribers(String event)
Get all subscribers to a particular event
|
void |
handleEvent(SseEvent event) |
boolean |
hasSubscribers(String event)
Check if a particular event has subscribers
|
void |
registerClient(String clientId,
org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) |
void |
registerClient(String clientId,
org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter,
boolean completeAfterMessage) |
void |
setDataObjectConverters(List<DataObjectConverter> dataObjectConverters) |
void |
subscribe(String clientId)
Subscribe to the default event (message)
|
void |
subscribe(String clientId,
String event) |
void |
subscribeOnly(String clientId,
String event)
Subscribe to the event and unsubscribe to all other currently subscribed events
|
void |
unregisterClient(String clientId) |
void |
unsubscribe(String clientId,
String event) |
void |
unsubscribeFromAllEvents(String clientId,
String... keepEvents)
Unsubscribe the client from all events except the events provided with the
keepEvents parameter.
|
public SseEventBus(SseEventBusConfigurer configurer, SubscriptionRegistry subscriptionRegistry)
@PreDestroy public void cleanUp()
public org.springframework.web.servlet.mvc.method.annotation.SseEmitter createSseEmitter(String clientId)
public org.springframework.web.servlet.mvc.method.annotation.SseEmitter createSseEmitter(String clientId, String... events)
public org.springframework.web.servlet.mvc.method.annotation.SseEmitter createSseEmitter(String clientId, boolean unsubscribe, String... events)
public org.springframework.web.servlet.mvc.method.annotation.SseEmitter createSseEmitter(String clientId, Long timeout, String... events)
public org.springframework.web.servlet.mvc.method.annotation.SseEmitter createSseEmitter(String clientId, Long timeout, boolean unsubscribe, String... events)
public org.springframework.web.servlet.mvc.method.annotation.SseEmitter createSseEmitter(String clientId, Long timeout, boolean unsubscribe, boolean completeAfterMessage, String... events)
SseEmitter and registers the client in the internal database.
Client will be subscribed to the provided events if specified.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 subscribepublic void registerClient(String clientId, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter)
public void registerClient(String clientId, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter, boolean completeAfterMessage)
public void unregisterClient(String clientId)
public void subscribe(String clientId)
public void subscribeOnly(String clientId, String event)
public void unsubscribeFromAllEvents(String clientId, String... keepEvents)
@EventListener public void handleEvent(SseEvent event)
public List<DataObjectConverter> getDataObjectConverters()
public void setDataObjectConverters(List<DataObjectConverter> dataObjectConverters)
public Set<String> getAllClientIds()
public Set<String> getAllEvents()
public Map<String,Set<String>> getAllSubscriptions()
public Set<String> getSubscribers(String event)
public int countSubscribers(String event)
public boolean hasSubscribers(String event)
Copyright © 2016–2020. All rights reserved.