Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
{io} = require './server'
net = require 'net'
{EventEmitter} = require 'events'
EE = new EventEmitter
server = net.createServer (client) ->
console.log 'client connected'
client.on 'end', ->
console.log 'client disconnected'
client.on 'error', (error) ->
console.log error
client.on 'data', (data) ->
console.log data.toString()
EE.emit 'data', data.toString()
server.listen 8100
io.sockets.on 'connection', (socket) ->
EE.on 'data', (data) ->
console.log 'data'
socket.emit 'data', data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment