-
-
Save odino/1370310 to your computer and use it in GitHub Desktop.
gist.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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