Skip to content

Instantly share code, notes, and snippets.

@odino
Forked from s3u/gist:1370108
Created November 16, 2011 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odino/1370310 to your computer and use it in GitHub Desktop.
Save odino/1370310 to your computer and use it in GitHub Desktop.
gist.js
function probe(cb) {
var wsCtor = window['MozWebSocket'] ? MozWebSocket : WebSocket;
var socket = new wsCtor(uri, 'blah');
socket.onopen = function () {
// Send a probe
socket.send(JSON.stringify({
type: 'probe',
data: {}
}));
};
socket.onerror = function() {
cb('Not supported');
}
socket.onmessage = function(e) {
cb();
}
socket.onclose = function() {
cb('Not supported');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment