this.wampSession.call("returnMethod", arglist).then(successCB, errorCB);
};
+cloudeebus.Service.prototype.emitSignal = function(objectPath, signalName, result, successCB, errorCB) {
+ var arglist = [
+ objectPath,
+ signalName,
+ result
+ ];
+
+ this.wampSession.call("emitSignal", arglist).then(successCB, errorCB);
+};
+
/*****************************************************************************/
attrib['type'])
return
if (self.current == 'signal'):
+ if (attrib.has_key('name') == False):
+ attrib['name'] = 'value'
self.dynDBusClass.add_signature(attrib['name'], 'in',
attrib['type'])
return
@exportRpc
+ def emitSignal(self, list):
+ '''
+ arguments: agentObjectPath, signalName, result (to emit)
+ '''
+ objectPath = list[0]
+ className = re.sub('/', '_', objectPath[1:])
+ signalName = list[1]
+ result = list[2]
+ if (self.serviceAgents.has_key(className) == True):
+ exe_str = "self.serviceAgents['"+ className +"']."+ signalName + "(" + str(result) + ")"
+ eval(exe_str, self.globalCtx, self.localCtx)
+ else:
+ raise Exception("No object path " + objectPath)
+
+ @exportRpc
def returnMethod(self, list):
'''
arguments: methodId, callIndex, success (=true, error otherwise), result (to return)
// sampleProxy.Release();
}
+function signalHandler(aSum) {
+ cloudeebus.log("signal 'ResultChanged': " + aSum);
+}
+
function gotProxy(proxy) {
logCB(proxy);
for (var i=-10; i<10; i++)
proxy.Add(i,i*2,gotAddResult,errorCB);
sampleProxy = proxy;
+ sampleProxy.connectToSignal("org.cloudeebus.Sample", "ResultChanged", signalHandler);
+
}
function connectSuccess() {
<body>
<center><h1>cloudeebus</h1></center>
<br>
- <textarea style="width:80%" rows="32" id="script">var sampleXml= '<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"\n"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">\n<node><interface name="org.cloudeebus.Sample"><method name="Release"></method><method name="Add"><arg type="i" name="arg1"/><arg type="i" name="arg2"/><arg type="i" name="result" direction="out"/></method></interface></node>';
+ <textarea style="width:80%" rows="32" id="script">var sampleXml= '<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"\n"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">\n<node><interface name="org.cloudeebus.Sample"><method name="Release"></method><method name="Add"><arg type="i" name="arg1"/><arg type="i" name="arg2"/><arg type="i" name="result" direction="out"/></method><signal name="ResultChanged"><arg type="i" name="result"/></signal></interface></node>';
cloudeebus.log = function(msg) {
document.getElementById("log").innerHTML += msg + "\n";
}
function addCalled(args) {
var methodId = arguments[0];
+ var objPath = methodId.split("#")[1];
var callDict = JSON.parse(arguments[1]);
cloudeebus.log("Method called: " + methodId);
- cloudeebus.log("Add: " + callDict.args[0] + " + " + callDict.args[1] + " = " + (callDict.args[0] + callDict.args[1]));
- cloudeebus.SessionBus().service.returnMethod(methodId, callDict.callIndex, true, callDict.args[0] + callDict.args[1]);
+ result = callDict.args[0] + callDict.args[1];
+ cloudeebus.log("Add: " + callDict.args[0] + " + " + callDict.args[1] + " = " + result);
+ cloudeebus.SessionBus().service.returnMethod(methodId, callDict.callIndex, true, result);
+ cloudeebus.log("Emit signal 'ResultChanged' with value " + result);
+ cloudeebus.SessionBus().service.emitSignal(objPath, "ResultChanged", result);
}
function releaseCalled() {