summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorNo'am Rosenthal <noam.rosenthal@nokia.com>2011-07-13 16:53:52 -0700
committerNo'am Rosenthal <noam.rosenthal@nokia.com>2011-07-13 16:53:52 -0700
commite887e8f0130b9290157aac9629ec8cc83f48b9d0 (patch)
tree2cbb6f2e390cd2c36a6848db5e0f5a26e4bf13dd /examples
parentb49ccb384eb37f821c06c1e68dd3ca11837f54c6 (diff)
downloadqtwebchannel-e887e8f0130b9290157aac9629ec8cc83f48b9d0.tar.gz
Switch from WebSockets to Comet
Diffstat (limited to 'examples')
-rw-r--r--examples/qmlapp/index.html8
-rw-r--r--examples/qmlapp/qmlapp.qml20
2 files changed, 22 insertions, 6 deletions
diff --git a/examples/qmlapp/index.html b/examples/qmlapp/index.html
index 4004346..e1a4bf6 100644
--- a/examples/qmlapp/index.html
+++ b/examples/qmlapp/index.html
@@ -1,11 +1,13 @@
<html>
<head>
- <script src="../../src/qwebchannel.js"></script>
+ <script src="../../src/qwebchannel.js"></script>
<script>
function load() {
- navigator.webChannel.init();
+ navigator.webChannel.subscribe("incoming-call",
+ function(message) { debug(message); }
+ );
navigator.webChannel.exec({a:"This is a request from HTML"}, function(response) {
- document.body.innerHTML = response.b;
+ debug(response.b);
});
}
</script>
diff --git a/examples/qmlapp/qmlapp.qml b/examples/qmlapp/qmlapp.qml
index 06f9cdc..9872c9d 100644
--- a/examples/qmlapp/qmlapp.qml
+++ b/examples/qmlapp/qmlapp.qml
@@ -8,8 +8,9 @@ Rectangle {
WebChannel {
id: webChannel
useSecret: false
+
onRequest: {
- var data = JSON.parse(request);
+ var data = JSON.parse(requestData);
txt.text = data.a;
response.send(JSON.stringify({b:'This is a response from QML'}));
}
@@ -21,11 +22,24 @@ Rectangle {
height: 200
settings.localContentCanAccessRemoteUrls: true
settings.developerExtrasEnabled: true
- url: "index.html?baseUrl=" + webChannel.baseUrl
+ url: "index.html?webchannel_baseUrl=" + webChannel.baseUrl
}
+ TextEdit {
+ width: 1000
+ height: 100
+ id: editor
+ anchors.top: parent.top
+ }
Text {
id: txt
- anchors.top: parent.top
+ anchors.top: editor.bottom
+ text: "BLA"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ webChannel.broadcast("incoming-call", JSON.stringify(editor.text));
+ }
+ }
}
}