Javascript inter application communication

this is made to allow applications within a page to exchange data. This library is made for broadcasting messages on topic. This is basically based on 3 functions : subscribe, publish and unsubscribe.

when you subscribe to a topic, you receive all the subtopic message. for example, if I subscribe to "/eXo/application", and an application send a message on "/eXo/application/map", i will receive it, but if another application send a message on "/eXo", i will not receive it.

common topics

/eXo

it contains all the events generated by the platform.

/eXo/portal/notification

when a message is sent on this topic, a popup message appears on the top right of the screen

/eXo/portal/changeTitle (not implemented yet)

send a message on this channel to change (and to be notified) the title of the portal

/eXo/portal/pageLoaded (not implemented yet)

receive a message at every page Loaded

/eXo/portal/pageUnloaded (not implemented yet)

receive a message at every page unloaded

/eXo/application/applicationLoaded (not implemented yet)

receive a message at every application loaded in the page

/eXo/application/applicationUnloaded (not implemented yet)

receive a message at every application Unloaded in the page

library

The inter application communication http://fisheye.exoplatform.org/projects/browse/projects/portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/core/Topic.js

Syntax

eXo.core.Topic.subscribe = function(/*String*/ topic, /*Object*/ obj, /*String*/ funcName)

subscribe is used to subscribe a callback to a topic

Parameters:

  • topic is the topic that will be listened
  • obj is the context object
  • funcName is the name of the function of obj to call when a message is received on the topic
funcName have to be a function that take an Object in parameter. the event received have this format:
{
  senderId:senderId,
  message:message,
  topic: topic
}

eXo.core.Topic.publish = function(/*String*/ senderId, /*String*/ topicName, /*Object*/ message)

publish is used to publish an event to the other subscribers to the given channels

Parameters:

  • senderId is a string that identify the sender
  • topic is the topic that the message will be published
  • message is the message that's going to be delivered to the subscribers to the topic

eXo.core.Topic.unsubscribe = function(/*String*/ topic, /*Object*/ obj, /*String*/ funcName)

unsubscribe is used to unsubscribe a callback to a topic

Parameters:

  • topic is the topic that will be unsubscribe
  • obj is the context object
  • funcName function name givent at the previous subscribe

example

Topic Demo


Creator: jeremi joslin on 2008/01/17 09:35
Copyright (c) 2000-2009. Allright reserved - eXo platform SAS
1.6.13286