Class Index | File Index

## Classes

- _global_
- OWF
- OWF.Chrome
- OWF.DragAndDrop
- OWF.Eventing
- OWF.Intents
- OWF.Lang
- OWF.Launcher
- OWF.Log
- OWF.Metrics
- OWF.Preferences
- OWF.RPC
- OWF.Util
- Ozone.chrome.WidgetChrome
- Ozone.dragAndDrop.WidgetDragAndDrop
- Ozone.eventing.Widget
- Ozone.eventing.WidgetProxy
- Ozone.lang
- Ozone.launcher.WidgetLauncher
- Ozone.launcher.WidgetLauncherUtils
- Ozone.log
- Ozone.metrics
- Ozone.pref.PrefServer
- Ozone.state.WidgetState
- Ozone.state.WidgetStateHandler
- Ozone.util
- Ozone.util.pageLoad

# Namespace OWF.RPC

Defined in: Widget.js.

Namespace Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| OWF.RPC

Method Summary
Method Attributes | Method Name and Description
--- | ---
<static> | OWF.RPC.getWidgetProxy(instanceGuid, callback) Gets a proxy object that contains methods exposed by other widget.
<static> | OWF.RPC.handleDirectMessage(fn) Register a function to be executed when a direct message is received from another widget.
<static> | OWF.RPC.registerFunctions(objs) Register one or more functions to OWF to expose to other widgets.

Namespace Detail
OWF.RPC
Method Detail
<static> OWF.RPC.getWidgetProxy(instanceGuid, callback)
Gets a proxy object that contains methods exposed by other widget.

    OWF.RPC.getWidgetProxy('instanceGuid of widgetA', function(widgetA) {

    	widgetA.add(1,2,3, function(result) {
    		console.log(result); // log the result
    	})

    	widgetA.sendMessage('some secret message');

    });

Parameters:
{String} instanceGuid
  instance guid of the widget to import
{Function} callback
  function that will be executed if the widget is found opened on the current dashboard. The function is passed a proxy object as the first argument which will contain methods that were exposed by the widget. In addition, the proxy abject also has sendMessage method to send a direct message to the widget.

<static> OWF.RPC.handleDirectMessage(fn)
Register a function to be executed when a direct message is received from another widget.

    OWF.RPC.handleDirectMessage(function(msg) {
    	// do something with the message
    });

Parameters:
{Function} fn
  function that will be executed when a direct message is received from another widget.

<static> OWF.RPC.registerFunctions(objs)
Register one or more functions to OWF to expose to other widgets.

    Calculator = {
    	add: function() {
    		var args = arguments,
    			val = 0;
    		for(var i = 0, len = args.length; i < len; i++) {
    			val += parseFloat(args[i]);
    		}
    		return val;
    	},
    	multiply: function() {
    		var args = arguments,
    			val = 1;
    		for(var i = 0, len = args.length; i < len; i++) {
    			val *= parseFloat(args[i]);
    		}
    		return val;
    	}
    };
    OWF.RPC.registerFunctions([
    	{
    		name: 'add'
    		fn: Calculator.add,
    		scope: Calculator
    	},
    	{
    		name: 'multiply'
    		fn: Calculator.multiply,
    		scope: Calculator
    	}
    ]);

Parameters:
{Object/Array} objs
  Object or an array of objects of following structure.
  {
  name: 'name of the function',
  fn: function() {},
  scope: window //The scope (this reference) in which the function is executed. If omitted, defaults to the browser window.
  }

Documentation generated by JsDoc Toolkit 2.3.2 on Fri Dec 21 2012 17:25:00 GMT-0500 (EST)