Skip to content

Instantly share code, notes, and snippets.

@rexstjohn
Created February 8, 2015 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rexstjohn/0ac6afa74cc0a358e2a0 to your computer and use it in GitHub Desktop.
Save rexstjohn/0ac6afa74cc0a358e2a0 to your computer and use it in GitHub Desktop.
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