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)
31 io.sockets.on 'connection', (socket) ->
33 socket.on 'disconnect', ->
34 for i in [i...sockets.length]
35 if sockets[i] is socket
39 socket.emit 'init', width: term.width, height: term.height, x: term.x, y: term.y, a: term.a, text: term.text, attributes: term.attributes
41 process.stdin.resume()
42 process.stdin.setEncoding 'utf8'
44 process.stdin.on 'data', (data) ->
46 # FIXME send data, and have client parse it
48 s.emit 'init', width: term.width, height: term.height, x: term.x, y: term.y, a: term.a, text: term.text, attributes: term.attributes
50 process.stdin.on 'end', -> process.exit()