Skip to content

Instantly share code, notes, and snippets.

@stefanoortisi
Last active August 29, 2015 13:58
Show Gist options
  • Save stefanoortisi/10146216 to your computer and use it in GitHub Desktop.
Save stefanoortisi/10146216 to your computer and use it in GitHub Desktop.
fs = require("fs")
http = require("http")
socketio = require("socket.io")
public_path = "#{__dirname}/../public"
server = http.createServer((req, res) ->
res.writeHead 200, "Content-type": "text/html"
res.end fs.readFileSync "#{public_path}/index.html"
).listen(8765)
socketio.listen(server).on "connection", (socket) ->
socket.on "message", (msg) ->
socket.broadcast.emit "message", msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment