summaryrefslogtreecommitdiff
path: root/src/webchannel/qwebchannel.js
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2014-07-30 12:20:08 +0200
committerLutz Schönemann <lutz.schoenemann@basyskom.com>2014-12-08 16:02:45 +0100
commit0a43a43a166d2e2b551f543de61090637bd8b387 (patch)
treeb27ead870eef7af20f3d35a717d57bd0d262a911 /src/webchannel/qwebchannel.js
parente50edc952ce15f3c11f4cdfad74ec984043cb080 (diff)
downloadqtwebchannel-0a43a43a166d2e2b551f543de61090637bd8b387.tar.gz
Do not broadcast initialization data to all clients.
Instead, send the data as a response to the initialization request message. This simplifies the code and makes it more predictable, as we do not spam all clients with initialization broadcasts anymore. Note that the pending initialization "feature" is removed, but I don't see a need for it anymore. If you want to delay client initialization, do it on the client side. Change-Id: I1ab71fd6c9e809ccb6085f1a3fbac3eb9b2e910b Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'src/webchannel/qwebchannel.js')
-rw-r--r--src/webchannel/qwebchannel.js29
1 files changed, 8 insertions, 21 deletions
diff --git a/src/webchannel/qwebchannel.js b/src/webchannel/qwebchannel.js
index d2c6525..13e9da5 100644
--- a/src/webchannel/qwebchannel.js
+++ b/src/webchannel/qwebchannel.js
@@ -82,9 +82,6 @@ var QWebChannel = function(transport, initCallback)
case QWebChannelMessageTypes.propertyUpdate:
channel.handlePropertyUpdate(data);
break;
- case QWebChannelMessageTypes.init:
- channel.handleInit(data);
- break;
default:
console.error("invalid message received:", message.data);
break;
@@ -149,30 +146,20 @@ var QWebChannel = function(transport, initCallback)
channel.exec({type: QWebChannelMessageTypes.idle});
}
- // prevent multiple initialization which might happen with multiple webchannel clients.
- this.initialized = false;
- this.handleInit = function(message)
+ this.debug = function(message)
{
- if (channel.initialized) {
- return;
- }
- channel.initialized = true;
- for (var objectName in message.data) {
- var data = message.data[objectName];
- var object = new QObject(objectName, data, channel);
+ channel.send({type: QWebChannelMessageTypes.debug, data: message});
+ };
+
+ channel.exec({type: QWebChannelMessageTypes.init}, function(data) {
+ for (var objectName in data) {
+ var object = new QObject(objectName, data[objectName], channel);
}
if (initCallback) {
initCallback(channel);
}
channel.exec({type: QWebChannelMessageTypes.idle});
- }
-
- this.debug = function(message)
- {
- channel.send({type: QWebChannelMessageTypes.debug, data: message});
- };
-
- channel.exec({type: QWebChannelMessageTypes.init});
+ });
};
function QObject(name, data, webChannel)