1 handler = (req, res) ->
3 res.writeHead(404, 'Content-Type': 'text/plain')
4 return res.end("Error loading #{req.url}")
6 when '/', '/index.html'
7 filename = __dirname + '/index.html'
10 filename = '/usr/share/javascript/jquery/jquery.min.js'
11 type = 'text/javascript'
14 fs.readFile filename, (err, data) ->
15 return err req, res if err
17 res.writeHead(200, 'Content-Type': type)
20 app = require('http').createServer(handler)
21 io = require('socket.io').listen(app)
23 terminal = require('./terminal.coffee')
27 term = terminal.new(105, 66)
29 io.sockets.on 'connection', (socket) ->
30 # FIXME socket.emit 'write', term.getState()
31 term.on 'sequence', (data) ->
32 socket.emit 'write', "sequence: #{data}"
33 term.on 'text', (data) ->
34 socket.emit 'write', data
35 socket.on 'disconnect', ->
36 # FIXME stop term update callback
37 console.log 'client disconnected'
39 process.stdin.resume()
40 process.stdin.setEncoding 'utf8'
42 process.stdin.on 'data', (data) ->
45 process.stdin.on 'end', -> process.exit()