Messenger namespace
From Genesys Documentation
Contents
Learn about the Messenger namespace methods in the Service Client API.
Methods
The Messenger namespace includes the following methods:
broadcastMessage
Signature | <static> broadcastMessage(channel, message, succeeded, failed) | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description | Send a message to other web applications that use the Service Client API and have subscribed to the specified channel. | |||||||||||||||
Parameters |
|
Samples
// Add a new message broadcaster:
genesys.wwe.service.messenger.broadcastMessage("my-channel", { foo: "A foo text.", bar: 1234 }, succeeded, failed)
// The operation "broadcastMessage" from the service "messenger" takes a channel name and any JSON-compliant object.
// In order to receive this message, you must "subscribe" to "my-channel":
genesys.wwe.service.subscribe([ "messenger:my-channel" ], function(message) { console.log("message: " + message.data); }, this);
// It is possible to subscribe to several channels:
genesys.wwe.service.subscribe([ "messenger:my-channel", "messenger:my-channel2" ], function(message) {
console.log("message: " + message.data + ", channel: " + message.event);
}, this);
messenger:<channel>
with the message in the data
attribute. For example, here's the event for the broadcast in the sample above:{
"event": "messenger:my-channel",
"data": {
"foo": "A foo text.",
"bar": 1234
},
"userAgent": "WWE Server",
"protocolVersion": 2
}
Comments or questions about this documentation? Contact us for support!