this.wampSession.subscribe(methodId, methodHandler);
};
-cloudeebus.Service.prototype.returnMethod = function(methodId, success, result, successCB, errorCB) {
+cloudeebus.Service.prototype.returnMethod = function(methodId, callIndex, success, result, successCB, errorCB) {
var arglist = [
methodId,
+ callIndex,
success,
result
];
@exportRpc
def returnMethod(self, list):
'''
- arguments: methodId, success (=true, error otherwise), result (to return)
+ arguments: methodId, callIndex, success (=true, error otherwise), result (to return)
'''
methodId = list[0]
- success = list[1]
- result = list[2]
+ callIndex = list[1]
+ success = list[2]
+ result = list[3]
if (self.servicePendingCalls.has_key(methodId)):
- cb = self.servicePendingCalls[methodId]
+ cb = self.servicePendingCalls[methodId]['calls'][callIndex]
+ if cb is None:
+ raise Exception("No pending call " + str(callIndex) + " for methodID " + methodId)
if (success):
successCB = cb["successCB"]
if (result != None):
errorCB(result)
else:
errorCB()
- del self.servicePendingCalls[methodId]
+ self.servicePendingCalls[methodId]['calls'][callIndex] = None
+ self.servicePendingCalls[methodId]['count'] = self.servicePendingCalls[methodId]['count'] - 1
+ if self.servicePendingCalls[methodId]['count'] == 0:
+ del self.servicePendingCalls[methodId]
else:
raise Exception("No methodID " + methodId)
methodId = self.srvName + "#" + self.agentObjectPath + "#" + name
cb = { 'successCB': async_succes_cb,
'errorCB': async_error_cb}
- self.servicePendingCalls[methodId] = cb
- factory.dispatch(methodId, json.dumps(args))
+ if methodId not in self.servicePendingCalls:
+ self.servicePendingCalls[methodId] = {'count': 0, 'calls': []}
+ pendingCallStr = json.dumps({'callIndex': len(self.servicePendingCalls[methodId]['calls']), 'args': args})
+ self.servicePendingCalls[methodId]['calls'].append(cb)
+ self.servicePendingCalls[methodId]['count'] = self.servicePendingCalls[methodId]['count'] + 1
+ factory.dispatch(methodId, pendingCallStr)
@exportRpc
def serviceAdd(self, list):
function gotProxy(proxy) {
logCB(proxy);
- proxy.Add(32,16,gotAddResult,errorCB);
+ for (var i=-10; i<10; i++)
+ proxy.Add(i,i*2,gotAddResult,errorCB);
sampleProxy = proxy;
}
}
function addCalled(args) {
-var args = JSON.parse(arguments[1]);
- cloudeebus.log("Add method called: " + args[0] + " + " + args[1]);
- cloudeebus.SessionBus().service.returnMethod("org.cloudeebus.Sample#/org/cloudeebus/Sample#Add", true, args[0] + args[1]);
+ var methodId = arguments[0];
+ 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]);
}
function releaseCalled() {
- cloudeebus.log("Release method called");
- cloudeebus.SessionBus().service.returnMethod("org.cloudeebus.Sample#/org/cloudeebus/Sample#Release", true, null);
- cloudeebus.SessionBus().service.wampSession.unsubscribe("org.cloudeebus.Sample#/org/cloudeebus/Sample#Release");
+ var methodId = arguments[0];
+ var callDict = JSON.parse(arguments[1]);
+ cloudeebus.log("Method called: " + methodId);
+ cloudeebus.SessionBus().service.returnMethod(methodId, 0, true, null);
+ cloudeebus.SessionBus().service.wampSession.unsubscribe(methodId);
cloudeebus.SessionBus().service.delAgent("/org/cloudeebus/Sample", logCB, errorCB);
cloudeebus.SessionBus().service.remove(logCB, errorCB);
}