by axod · 15y ago · 0 comments
In Mibbit, the code is something like this:
if(WebSocket in window) {
tryWebsocket();
window.setTimeout(function() {
if (nothingHappened()) useComet()
}, 5*1000);
} else {
useComet();
}
Where comet in this case is keep alive long polling XHR.I find 5*1000 most readable in my source code though.
Feature detection first, connection detection second, then start degrading the transport until all options are exhausted.