Universal Messaging Developer Guide : Universal Messaging Web Client APIs : Javascript : Universal Messaging Web Client Development in JavaScript : Universal Messaging Channel Publish / Subscribe : Publish/Subscribe Tasks : Universal Messaging JavaScript : Using a Universal Messaging Channel
Universal Messaging JavaScript : Using a Universal Messaging Channel
This JavaScript code snippet demonstrates how to create a channel object, which allows you to publish or subscribe to a Universal Messaging channel:

var myChannel = mySession.getChannel("/fxdemo/prices");
Note that unlike the Enterprise APIs, the JavaScript API does not support programmatic creation of channels; instead, you can use the Enterprise Manager GUI to create a Universal Messaging Channel.
A channel object offers several methods. Three of the more important ones are:
*myChannel.subscribe()
*myChannel.unsubscribe()
*myChannel.publish(Event event)
Please see JavaScript API Documentation for Channels for information on all available methods on a channel.
Each of the above methods can invoke one or more optional user-specified callback functions which you can (and probably should) implement and assign as follows:

var myChannel = mySession.getChannel("/fxdemo/prices");

// Assign a handler function for Universal Messaging Events received on the Channel, then subscribe:
function myEventHandler(event) {
var dictionary = event.getDictionary();
console.log(dictionary.get("name") + " " + dictionary.get("bid"));
}

myChannel.on(Nirvana.Observe.DATA, myEventHandler);

myChannel.subscribe();

See Subscribing to a channel and Publishing Events to a channel.
Copyright © 2013-2014 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback