The three messaging functions require particular objects and definitions in their syntax:
The subscribe function is used to subscribe a callback to a topic. It uses the following parameters:
The topic that will be listened for.
The name of the object function to call when a message is received on the topic. It has to be a function that takes an Object parameter. The event received will have this format:
{
senderId:senderId,
message:message,
topic: topic
}
The publish function is used to publish an event to the other subscribered applications through the given channels. Its parameters are:
This is a string that identifies the sender.
The topic that the message will be published.
This is the message body to be delivered to the subscribers to the topic.
The unsubscribe function is used to unsubscribe a callback to a topic. The required parameters are:
The topic from which will be unsubscribed.
This is the context object.