Skip to content

Instantly share code, notes, and snippets.

@josephg
Created November 1, 2011 08:19
Show Gist options
  • Save josephg/1330141 to your computer and use it in GitHub Desktop.
Save josephg/1330141 to your computer and use it in GitHub Desktop.
echo server & client
connect = ->
clientio = require 'socket.io-client'
client = clientio.connect 'http://localhost:8999'
client.on 'connect', ->
console.warn 'Connected'
setInterval ->
console.time 'message'
client.send 'hi'
, 1000
client.on 'message', (msg) ->
console.timeEnd 'message'
io = require('socket.io').listen(8999, connect)
io.sockets.on 'connection', (socket) ->
socket.on 'message', (msg) ->
socket.send msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment