Universal Messaging 10.11 | Developer Guide | Web Client APIs | Web Developer's Guide for Javascript | Server Configuration for JavaScript | Serving From Another Webserver
 
Serving From Another Webserver
The Universal Messaging JavaScript API consists of two files:
*nirvana.js (which can be served from any webserver)
*crossDomainProxy.html (needed only if using one of the postMessage drivers, and which must be served from a file plugin on the Universal Messaging realm server)
Universal Messaging Realm Servers provide the option of exposing an HTTP web server interface for serving files to clients, removing the need to install a third party web server for hosting applications. Of course, it is possible to use a third party web server to host applications too.
Here we will explain how to deploy applications in both scenarios.
Web Applications on a Realm File Plugin
Your application source code, and the Universal Messaging library files shown above, need to be deployed to one or more directories on the Realm Server, and File Plugins configured to provide access to these directories.
Note:
Universal Messaging ships with an HTTP Interface enabled by default. This HTTP Interface is pre-configured with a file plugin with the base path /lib/js which points to the directory containing the above library files.
As a result, both files are accessible via a browser at the following paths on the realm:
*/lib/js/nirvana.js
*/lib/js/crossDomainProxy.html
To use Universal Messaging, applications then simply need to include nirvana.js as follows:

<script src="/lib/js/nirvana.js"></script>
There is no need to reference the crossDomainProxy.html file directly (the nirvana.js library will load it automatically if it is required).
Your Universal Messaging session can be started with a relatively simple configuration, as follows:

var mySession = Nirvana.createSession({
applicationName : "myExampleApplication",
sessionName : "myExampleSession",
username : "testuser"
});
mySession.start();
Web Applications on a Third Party Web Server
Your application source code and HTML files, and optionally the nirvana.js library (which may in fact be served from any server, including a CDN), are deployed to a third party web server, such as Apache.
If there is any chance that your client will use a postMessage drivers, then you must ensure that the crossDomainProxy.html file is accessible on the realm via a file plugin.
If you use the default file plugin configuration mentioned above, then no further configuration is required. If instead you decide to make the crossDomainProxy.html file available at a different path by using a different file plugin, then you will need to specify this path as a crossDomainPath key in the session configuration object passed to Nirvana.createSession().
For any driver other than WEBSOCKET, the third party web server must be using the same protocol (i.e. http or https) as the Universal Messaging Realm interface file plugin, and running on the same port. The WEBSOCKET driver does not have this restriction.
To use Universal Messaging:
1. Applications need to include nirvana.js as follows:

<script src="/front/end/server/lib/nirvana.js"></script>
2. The Nirvana.createSession() call must use a configuration object that includes the following key/value pair:
*realms : An array of URLs of the realm servers in use, e.g.
["http://node1.um.softwareag.com:80", "http://node2.um.softwareag.com:80"]
3. Your Universal Messaging session can then be started with a configuration such as:

var mySession = Nirvana.createSession({
realms : ["http://node1.um.softwareag.com:80",
"http://node2.um.softwareag.com:80"],
applicationName : "myExampleApplication",
sessionName : "myExampleSession",
username : "testuser"
});
mySession.start();
For more information, please see Universal Messaging Sessions in JavaScript, which describes in more detail the options that can be set using the Universal Messaging session configuration object.