From 2deecd5f7ca46d58e9167a323b71e230a768fbfd Mon Sep 17 00:00:00 2001 From: Frederic PAUT Date: Mon, 22 Jul 2013 14:42:02 +0200 Subject: [PATCH] dbus service : avoiding multi-connection on each 'run script' button --- doc/agent/client.html | 22 ++++++++++++++-------- doc/agent/server.html | 3 ++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/doc/agent/client.html b/doc/agent/client.html index 5b92c4d..625d3a1 100644 --- a/doc/agent/client.html +++ b/doc/agent/client.html @@ -53,29 +53,35 @@ function signalHandler(result) { } function gotProxy(proxy) { - if (window.sampleProxy == null) - proxy.connectToSignal("org.cloudeebus.Sample", "ResultChanged", signalHandler); - window.sampleProxy = proxy; + proxy.connectToSignal("org.cloudeebus.Sample", "ResultChanged", signalHandler); logCB(proxy); - + window.sampleProxy = proxy; + testProxy(); +} + +function testProxy() { var dictionary = {Name: "Mickey", Sisters: [""], Married: true, Divorced: 0, Friends: ["Donald", "Dingo"], Others: [""]}; - proxy.Variant(dictionary).then(logCB,errorCB); + window.sampleProxy.Variant(dictionary).then(logCB,errorCB); logCB('Addition'); for (var i=-2; i<2; i++) - proxy.Add(i,i*2).then(gotAddResult,errorCB); + window.sampleProxy.Add(i,i*2).then(gotAddResult,errorCB); } function connectSuccess() { - cloudeebus.SessionBus().getObject("org.cloudeebus.Sample", "/org/cloudeebus/Sample", gotProxy, errorCB); + cloudeebus.SessionBus().getObject("org.cloudeebus.Sample", "/org/cloudeebus/Sample", gotProxy, errorCB); } -cloudeebus.connect("ws://localhost:9002", manifest, connectSuccess, errorCB); +if (!window.sampleProxy) + cloudeebus.connect("ws://localhost:9002", manifest, connectSuccess, errorCB); +else + testProxy(); +
diff --git a/doc/agent/server.html b/doc/agent/server.html index 7f6ea5e..47f7ba9 100644 --- a/doc/agent/server.html +++ b/doc/agent/server.html @@ -70,7 +70,8 @@ function connectSuccess() { cloudeebus.SessionBus().addService("org.cloudeebus.Sample").then(addAgent, errorCB); } -cloudeebus.connect("ws://localhost:9003", manifest, connectSuccess, errorCB); +if (!window.sampleProxy) + cloudeebus.connect("ws://localhost:9003", manifest, connectSuccess, errorCB);
- -- 2.7.4