Skip to content

Instantly share code, notes, and snippets.

@clooth
Created August 26, 2012 02:47
Show Gist options
  • Save clooth/3473287 to your computer and use it in GitHub Desktop.
Save clooth/3473287 to your computer and use it in GitHub Desktop.
// Generated by CoffeeScript 1.3.3
(function() {
var app, fs, handler, io;
app = require('http').createServer(handler);
io = require('socket.io').listen(app);
fs = require('fs');
app.listen(8100);
handler = function(request, response) {
return fs.readFile(__dirname + '/index.html', function(error, data) {
console.log('Foobar');
if (error) {
response.writeHead(500);
return response.end('Error loading index.html');
}
response.writeHead(200);
return response.end(data);
});
};
io.sockets.on('connection', function(socket) {
socket.emit('news', {
hello: 'world'
});
return socket.on('my other event', function(data) {
return console.log(data);
});
});
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment