Skip to content

Instantly share code, notes, and snippets.

@bradurani
Created July 25, 2017 21:33
Show Gist options
  • Save bradurani/06960dfb8454a13675d5c7c200583c62 to your computer and use it in GitHub Desktop.
Save bradurani/06960dfb8454a13675d5c7c200583c62 to your computer and use it in GitHub Desktop.
var websocket = new WebSocket('ws://echo.websocket.org/');
websocket.onopen = function(e) {
console.log('socket open');
}
websocket.onmessage = function (e){
console.log(e.data)
};
websocket.onclose = function(e){
console.log('connection closed')
};
window.setInterval(function(){
websocket.send('ping');
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment