Details about the JavaScript part of the extension

The client.js file (client side) for the qnx.volume extension is shown here:

 * Allows control of the volume 
 * @author myName
 * $Id$

var _ID = require("./manifest.json").namespace;

 * Exports are the publicly accessible functions
module.exports = {
	 * Returns the current volume
	 * @returns {Number} The current audio parameters
	get: function () {
	    return window.webworks.execSync(_ID, 'get');
	* Sets the volume
	* @param volume {Number} The new volume to set
    set: function (volume) {
	    window.webworks.execSync(_ID, 'set', { volume: volume });

The manifest.json file for the qnx.volume extension is shown here:

    "global": false,
    "namespace": "qnx.volume",
    "dependencies": []

As a consequence of how these files are written, the methods in qnx.volume are called as qnx.volume.get() and qnx.volume.set(x), where x = [0,100].

The interaction between client.js and index.js is made by using APIs of the WebWorks object webworks.js, which you copied to your app project directory earlier; every app will have a copy of this file.

The client side can make synchronous or asynchronous calls to the server side. When making a call to the server side, each method in client.js should provide the ID, method name, and arguments to execSync to get a synchronized call or to execAsync when the request is asynchronous. This results in the invocation of a corresponding method name in index.js. For qnx.volume, note that the calls are all synchronous.

If your extension needs to include events, make sure to define these events in index.js. Events are defined inside the _actionMap variable.For example, see the index.js file for the qnx.volume extension where the single event volumeupdate is defined.

An extension that includes events must provide two additional files: In context.js you must define the addEventListener and removeEventListener methods that are called from the app. Again, see the context.js file for the qnx.volume extension where these methods are defined for the volumeupdate event.

The second file you'll need if you're going to include events is the extension_name.js file, which is discussed in the next section ("Using the PPS interface").