Created
February 8, 2015 02:20
-
-
Save rexstjohn/0ac6afa74cc0a358e2a0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
app = require('http').createServer(handler) | |
io = require('socket.io')(app) | |
fs = require('fs') | |
handler = (req, res) -> | |
fs.readFile __dirname + '/index.html', (err, data) -> | |
if err | |
res.writeHead 500 | |
return res.end('Error loading index.html') | |
res.writeHead 200 | |
res.end data | |
return | |
return | |
app.listen 8000 | |
io.on 'connection', (socket) -> | |
socket.emit 'news', hello: 'world' | |
socket.on 'my other event', (data) -> | |
console.log data | |
return | |
return | |
# --- | |
# generated by js2coffee 2.0.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment