Created
April 8, 2012 17:05
-
-
Save Hounddog/2338517 to your computer and use it in GitHub Desktop.
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
server.js | |
var io = require('socket.io').listen(80); | |
io.sockets.on('connection', function (socket) { | |
socket.emit('news', { hello: 'world' }); | |
socket.on('my other event', function (data) { | |
console.log(data); | |
}); | |
}); | |
index.html | |
<script src="/socket.io/socket.io.js"></script> | |
<script> | |
var socket = io.connect('http://localhost'); | |
socket.on('news', function (data) { | |
console.log(data); | |
socket.emit('my other event', { my: 'data' }); | |
}); | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment