2.10.3. Syntax

The three messaging functions require particular objects and definitions in their syntax:

Subscribe

The subscribe function is used to subscribe a callback to a topic. It uses the following parameters:

topic

The topic that will be listened for.

func

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
}

Publish

The publish function is used to publish an event to the other subscribered applications through the given channels. Its parameters are:

senderId

This is a string that identifies the sender.

topicName

The topic that the message will be published.

message

This is the message body to be delivered to the subscribers to the topic.

Unsubscribe

The unsubscribe function is used to unsubscribe a callback to a topic. The required parameters are:

topic

The topic from which will be unsubscribed.

id

This is the context object.

Copyright ©2012. All rights reserved. eXo Platform SAS