Skip to content

Instantly share code, notes, and snippets.

@Hounddog
Created April 8, 2012 17:05
Show Gist options
  • Save Hounddog/2338517 to your computer and use it in GitHub Desktop.
Save Hounddog/2338517 to your computer and use it in GitHub Desktop.
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