Created
August 19, 2012 13:54
-
-
Save cacois/3394948 to your computer and use it in GitHub Desktop.
websocket test
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
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