Skip to content

Instantly share code, notes, and snippets.

@cacois
Created August 19, 2012 13:54
Show Gist options
  • Save cacois/3394948 to your computer and use it in GitHub Desktop.
Save cacois/3394948 to your computer and use it in GitHub Desktop.
websocket test
var socket;
function connect() {
// Create a websocket
var socket = new WebSocket('ws://localhost:8080');
// Define behavior
socket.onopen = function(event) {
socket.send('Hello Server!');
socket.onmessage = function(message) {
console.log('Message from server: ', message);
};
socket.onclose = function(event) {
console.log('Server has closed connection', event);
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment