Skip to content

Commit

Permalink
Fixes for IE 6 and Android 2.3.
Browse files Browse the repository at this point in the history
 - Exclude iframe transports which require SockJS-client
    to be served by Yeti.
 - Exclude xhr-streaming transport on Android UAs for
    faster connection startup.
 - Increase RTT for IE 6.
 - Cool down for 1 second after every test page for IE 6.
  • Loading branch information
reid committed Jun 12, 2012
1 parent d3950c3 commit ab10c71
Showing 1 changed file with 53 additions and 5 deletions.
58 changes: 53 additions & 5 deletions lib/hub/view/public/inject.js
Expand Up @@ -117,8 +117,8 @@
window.$yetify = function $yetify(firstRunConfiguration) {

var win = window,
ie6 = navigator.userAgent.indexOf("IE 6.") !== -1,
resultAttempts = 0,
tower = $yetify.tower,
Runner = null;

function sendResults() {
Expand All @@ -127,7 +127,7 @@
}
resultAttempts += 1;
status("Sending results, attempt " + resultAttempts + "...");
tower.emit("results", $yetify.results);
$yetify.tower.emit("results", $yetify.results);
$yetify.sendResultTimeout = win.setTimeout(sendResults, 5000);
}

Expand All @@ -139,6 +139,8 @@
var io = win.io,
resource = config.mountpoint,
sock,
protocols,
rtt,
tower;

if (resource === "/") {
Expand All @@ -147,7 +149,41 @@

status("Connecting...");

sock = new SockJS(getSockURL(resource, "tower"));
// iframe protocols are not used here, because
// the SockJS server needs to serve iframes
// using the same SockJS client JS as the parent.
//
// Currently, it's being served from the internet
// instead of by Yeti, so Yeti needs to serve
// the sock.js by itself before these can be
// enabled.
protocols = [
"websocket",
"xdr-streaming",
// "iframe-eventsource",
// "iframe-htmlfile",
"xdr-polling",
"xhr-polling",
// "iframe-xhr-polling",
"jsonp-polling"
];

if (navigator.userAgent.indexOf("Android") === -1) {
// Android 2.x timeouts for xhr-streaming,
// use it on other platforms.
protocols.push("xhr-streaming");
}

if (ie6) {
// IE 6 needs a longer RTT.
rtt = 2000;
// Leave it undefined for other browsers.
}

console.log("protos: " + protocols.join(","));
sock = new SockJS(getSockURL(resource, "tower"), null, {
protocols_whitelist: protocols
});
tower = $yetify.tower = new SimpleEvents(sock);

tower.queueUntil("listening");
Expand All @@ -167,9 +203,19 @@
};

tower.on("navigate", function (test) {
var navigateTimeout = 10;

$yetify.complete = true;
clearTimeout($yetify.sendResultTimeout);
document.location.href = test;

if (ie6) {
status("Cooling down for 1 second.");
navigateTimeout = 1000;
}

win.setTimeout(function () {
document.location.href = test;
}, navigateTimeout);
});

tower.on("listening", function () {
Expand Down Expand Up @@ -208,7 +254,9 @@
function beat() {
var element = document.getElementById("yeti-beat");
reportCarelessErrors();
tower.emit("beat");
// Sending heartbeats is noisy and we don't yet use them.
// Let SockJS keep the connection alive.
// $yetify.tower.emit("beat");
heartbeats += 1;
if (element) {
element.innerHTML = heartbeats;
Expand Down

0 comments on commit ab10c71

Please sign in to comment.