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.
This commit is contained in:
Michael Meeks
2011-11-10 10:12:28 +01:00
committed by Alexander Larsson
parent f711da3d1b
commit 14a17873de
4 changed files with 387 additions and 149 deletions

View File

@ -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++)