public class EventMessenger extends Object
EventMessages to either the
broker or directly to client. The EventMessenger is by default configured as a spring
managed bean and can be autowired into any other spring bean.
e.g.
@Service
public class MyService {
@Autowired
EventMessenger eventMessenger;
public void doSomething() {
eventMessenger.sendToAll("aTopic", "the message");
}
}
| Constructor and Description |
|---|
EventMessenger(org.springframework.messaging.MessageChannel brokerChannel,
org.springframework.messaging.MessageChannel clientOutboundChannel) |
| Modifier and Type | Method and Description |
|---|---|
void |
send(EventMessage eventMessage)
Send an EventMessage to the
SimpleBrokerMessageHandler. |
void |
sendDirect(EventMessage eventMessage)
Send an EventMessage directly to the client (
WampMessage.getWebSocketSessionId()). |
void |
sendTo(String topicURI,
Object event,
Set<String> eligibleWebSocketSessionIds)
Send an
EventMessage to every client that is currently subscribed to the
given topicURI and is listed in the eligibleSessionIds set. |
void |
sendTo(String topicURI,
Object event,
String eligibleWebSocketSessionId)
Send an
EventMessage to one client that is subscribed to the given
topicURI. |
void |
sendToAll(String topicURI,
Object event)
Send an
EventMessage to every client that is currently subscribed to the
given topicURI |
void |
sendToAllExcept(String topicURI,
Object event,
Set<String> excludeWebSocketSessionIds)
Send an
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 excludeWebSocketSessionId)
Send an
EventMessage to every client that is currently subscribed to the
provided topicURI except the one provided with the excludeSessionId parameter. |
void |
sendToDirect(String topicURI,
Object event,
Set<String> webSocketSessionIds)
Send an EventMessage directly to each client listed in the webSocketSessionId set
parameter.
|
void |
sendToDirect(String topicURI,
Object event,
String webSocketSessionId)
Send an EventMessage directly to the client specified with the webSocketSessionId
parameter.
|
void |
setSendTimeout(long sendTimeout) |
public EventMessenger(org.springframework.messaging.MessageChannel brokerChannel,
org.springframework.messaging.MessageChannel clientOutboundChannel)
public void sendToAll(String topicURI, Object event)
EventMessage to every client that is currently subscribed to the
given topicURItopicURI - the name of the topicevent - the payload of the EventMessagepublic void sendToAllExcept(String topicURI, Object event, String excludeWebSocketSessionId)
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 payload of the EventMessageexcludeWebSocketSessionId - a WebSocket session id that will be excludedpublic void sendToAllExcept(String topicURI, Object event, Set<String> excludeWebSocketSessionIds)
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 payload of the EventMessageexcludeWebSocketSessionIds - a set of WebSocket session ids that will be
excluded. If null or empty no client will be excluded.public void sendTo(String topicURI, Object event, Set<String> eligibleWebSocketSessionIds)
EventMessage to every client that is currently subscribed to the
given topicURI and is 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 payload of the EventMessageeligibleWebSocketSessionIds - only the WebSocket session ids listed here will
receive the EVENT message. If null or empty nobody receives the message.public void sendTo(String topicURI, Object event, String eligibleWebSocketSessionId)
EventMessage to one client that is subscribed to the given
topicURI. If the client with the given WebSocket session id is not subscribed to
the topicURI nothing happens.topicURI - the name of the topicevent - the payload of the EventMessageeligibleWebSocketSessionId - only the client with the WebSocket session id
listed here will receive the EVENT messagepublic void sendToDirect(String topicURI, Object event, Set<String> webSocketSessionIds)
In contrast to sendTo(String, Object, Set) this method does not check if
the receivers are subscribed to the destination. The
SimpleBrokerMessageHandler is not involved in sending these messages.
topicURI - the name of the topicevent - the payload of the EventMessagewebSocketSessionIds - list of receivers for the EVENT messagepublic void sendToDirect(String topicURI, Object event, String webSocketSessionId)
In contrast to sendTo(String, Object, String) this method does not check
if the receiver is subscribed to the destination. The
SimpleBrokerMessageHandler is not involved in sending this message.
topicURI - the name of the topicevent - the payload of the EventMessagewebSocketSessionId - receiver of the EVENT messagepublic void setSendTimeout(long sendTimeout)
public void send(EventMessage eventMessage)
SimpleBrokerMessageHandler. The broker looks up
if the receiver of the message (WampMessage.getWebSocketSessionId()) is
subscribed to the destination (PubSubMessage.getDestination()). If the
receiver is subscribed the broker sends the message to him.eventMessage - The event messagepublic void sendDirect(EventMessage eventMessage)
WampMessage.getWebSocketSessionId()).
In contrast to send(EventMessage) this method does not check if the
receiver is subscribed to the destination. The SimpleBrokerMessageHandler
is not involved in sending this message.
eventMessage - The event messagesend(EventMessage)Copyright © 2014–2017. All rights reserved.