       </Command>
     """
 
-  # Send the first few packets immediately to reduce latency
-  toInterpreter 'SupportedProtocols=1'
-  toInterpreter 'UsingProtocol=1'
-  toInterpreter '<?xml version="1.0" encoding="utf-8"?><Command><cmd>Identify</cmd><id>0</id><args><Identify><Sender><Process>RIDE.EXE</Process><Proxy>0</Proxy></Sender></Identify></args></Command>'
   toInterpreter '<?xml version="1.0" encoding="utf-8"?><Command><cmd>Connect</cmd><id>0</id><args><Connect><Token /></Connect></args></Command>'
 
   client.on 'end', -> log 'interpreter disconnected'; socket.emit 'end'
-  socket.on 'disconnect', -> log 'browser disconnected'; client.end()
+  socket.on 'disconnect', -> log 'browser disconnected'

server = https.createServer(httpsOptions, app).listen (httpsPort = 8443),
  -> log "HTTPS server listening on :#{httpsPort}"

io.listen(server).on 'connection', (socket) ->
  log 'browser connected'
  client = net.connect {host: '127.0.0.1', port: 4502}, -> log 'interpreter connected'

  toInterpreter = (s) ->
    log 'to interpreter: ' + JSON.stringify(s)[..1000]
    console.assert /[\x01-\x7f]*/.test s
    b = Buffer s.length + 8
    b.writeInt32BE b.length, 0
    b.write 'RIDE' + s, 4
    client.write b

  toBrowser = (m...) -> log 'to browser: ' + JSON.stringify(m)[..1000]; socket.emit m...


]

log = (s) -> console.info process.uptime().toFixed(3) + ' ' + s
b64 = (s) -> Buffer(s).toString 'base64'
b64d = (s) -> '' + Buffer s, 'base64'
getTag = (tagName, xml) -> (///^[^]*<#{tagName}>([^]*)</#{tagName}>[^]*$///.exec xml)?[1]

# preload files into memory so we can serve them faster
html = css = js = ''
do prepareHTML = ->
  html = fs.readFileSync 'index.html', 'utf8'
