   parser.process = (headers,body) ->
     if exports.debug
       util.log util.inspect headers: headers, body: body
+
+    # Rewrite headers as needed to work around some weirdnesses in
+    # the protocol;
+    # and assign unified event IDs to the ESL Content-Types.
 
     switch headers['Content-Type']
       when 'auth/request'


  sendmsg: (command,args,cb) -> @sendmsg_uuid null, command, args, cb

  # Execute an application for the given UUID (in client mode)

  execute_uuid: (uuid,app_name,app_arg,cb) ->

        event = 'esl_api_response'
      else
        event = headers['Content-Type']
    # Build request and response and send them out.
    req = new eslRequest headers,body
    res = new eslResponse socket
    socket.emit event, req, res
  # Get things started
  @emit 'esl_connect', new eslResponse socket if @emit?

#### ESL Server

class eslServer extends net.Server
  constructor: (requestListener) ->
    @on 'esl_connect', requestListener
    @on 'connection', connectionListener
    super()

# You can use createServer(callback) from your code.
exports.createServer = (requestListener) -> return new eslServer(requestListener)

#### ESL client
class eslClient extends net.Socket
  constructor: () ->
    @on 'connect', () -> connectionListener(this)
