summaryrefslogtreecommitdiff
path: root/gdk/broadway/broadway.js
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2011-11-10 10:12:28 +0100
committerAlexander Larsson <alexl@redhat.com>2011-11-10 10:12:28 +0100
commit14a17873de4451eb981bdb5325559efafeeda5f4 (patch)
treee2535c8eaf1b49268d3fb2ae7ef5425264cec0bd /gdk/broadway/broadway.js
parentf711da3d1b7c536ed7d7f89975928f2d8f05fd7a (diff)
downloadgtk+-14a17873de4451eb981bdb5325559efafeeda5f4.tar.gz
broadway: Initial support fro V7+ websockets
Allows more modern browsers eg. firefox 5+ to use gtk/broadway Auto-detects protocol version, and can switch between them at as you connect a different browser. This works to some extent, but seems to hang sometimes, for instance the "button box" test in testgtk never shows up.
Diffstat (limited to 'gdk/broadway/broadway.js')
-rw-r--r--gdk/broadway/broadway.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index 357620ee7b..90b9d53cff 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -2769,10 +2769,19 @@ function connect()
useToplevelWindows = true;
}
+ var loc = window.location.toString().replace("http:", "ws:");
+ loc = loc.substr(0, loc.lastIndexOf('/')) + "/socket";
+ var ws = null;
+
if ("WebSocket" in window) {
- var loc = window.location.toString().replace("http:", "ws:");
- loc = loc.substr(0, loc.lastIndexOf('/')) + "/socket";
- var ws = new WebSocket(loc, "broadway");
+ ws = new WebSocket(loc, "broadway");
+ } else if ("MozWebSocket" in window) { // Firefox 6
+ ws = new MozWebSocket(loc);
+ } else {
+ alert("WebSocket not supported, input will not work!");
+ return;
+ }
+
ws.onopen = function() {
inputSocket = ws;
var w, h;
@@ -2797,9 +2806,7 @@ function connect()
ws.onmessage = function(event) {
handleMessage(event.data);
};
- } else {
- alert("WebSocket not supported, input will not work!");
- }
+
setupDocument(document);
window.onunload = function (ev) {
for (var i = 0; i < toplevelWindows.length; i++)