Skip to content

Instantly share code, notes, and snippets.

@andreacfm
Created February 3, 2011 20:36
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 andreacfm/810140 to your computer and use it in GitHub Desktop.
Save andreacfm/810140 to your computer and use it in GitHub Desktop.
basic websocket js implementation
ws = new WebSocket('ws://{server_url}:{port});
ws.onopen = function(){
ws.send('hello');
}
ws.onmessage = function(ev){
do_things_with_incoming_message(ev.data);
}
ws.onclose = function(){
ws.send('bye bye');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment