public class EventMessenger extends Object
EventMessages back
to the client. This is a spring bean that can be autowired into any other
spring bean and allows any part of the application to send messages back to
the client
e.g.
@Service
public class MyService {
@Autowired
EventMessenger eventMessenger;
public void doSomething() {
eventMessenger.sendToAll("aTopic", "the message");
}
}
This is very similar to the
org.springframework.messaging.simp.SimpMessagingTemplate class from
Spring's STOMP support.
| Constructor and Description |
|---|
EventMessenger(PubSubHandler pubSubHandler) |
| Modifier and Type | Method and Description |
|---|---|
void |
sendTo(String topicURI,
Object event,
Set<String> eligibleSessionIds)
Send a
EventMessage to the clients that are subscribed to the
provided topicURI and are listed in the eligibleSessionIds set. |
void |
sendToAll(String topicURI,
Object event)
Send a
EventMessage to every client that is currently subscribed
to the provided topicURI |
void |
sendToAllExcept(String topicURI,
Object event,
Set<String> excludeSessionIds)
Send a
EventMessage to every client that is currently subscribed
to the provided topicURI except the ones listed in the excludeSessionIds
set. |
void |
sendToAllExcept(String topicURI,
Object event,
String excludeSessionId)
Send a
EventMessage to every client that is currently subscribed
to the provided topicURI except the one provided with the
excludeSessionId parameter. |
public EventMessenger(PubSubHandler pubSubHandler)
public void sendToAll(String topicURI, Object event)
EventMessage to every client that is currently subscribed
to the provided topicURItopicURI - the name of the topicevent - the messagepublic void sendToAllExcept(String topicURI, Object event, String excludeSessionId)
EventMessage to every client that is currently subscribed
to the provided topicURI except the one provided with the
excludeSessionId parameter.topicURI - the name of the topicevent - the messageexcludeSessionIds - a set of session ids that will be excludedpublic void sendToAllExcept(String topicURI, Object event, Set<String> excludeSessionIds)
EventMessage to every client that is currently subscribed
to the provided topicURI except the ones listed in the excludeSessionIds
set.topicURI - the name of the topicevent - the messageexcludeSessionIds - a set of session ids that will be excludedpublic void sendTo(String topicURI, Object event, Set<String> eligibleSessionIds)
EventMessage to the clients that are subscribed to the
provided topicURI and are listed in the eligibleSessionIds set. If no
session of the provided set is subscribed to the topicURI nothing
happens.topicURI - the name of the topicevent - the messageeligibleSessionIds - only the session ids listed here will receive
the messageCopyright © 2014. All Rights Reserved.