 #     # Open connection, send arbitrary API command, disconnect.
 #     fs_command = (cmd,cb) ->
 #       client = esl.createClient()
-#       client.on 'esl_auth_request', (req,res) ->
-#         res.auth 'ClueCon', (req,res) ->
-#           res.api cmd, (req,res) ->
-#             res.exit ->
+#       client.on 'esl_auth_request', ->
+#         this.auth 'ClueCon', ->
+#           this.api cmd, ->
+#             this.exit ->
 #               client.end()
 #       if cb?
 #         client.on 'close', cb

    @send "api #{command}"

  # Send an API command in the background.
  # The callback will receive the Job UUID (instead of the usual request/response pair).
  bgapi: (command,cb) ->
    @register_callback 'esl_command_reply', (req,res) ->
      r = res.header['Reply-Text']?.match /\+OK Job-UUID: (.+)$/
      cb? r[1]
    @send "bgapi #{command}"

  # Execute an application synchronously.
  # The callback is only called when the command has completed.
  command_uuid: (uuid,app_name,app_arg,cb) ->
    if cb?
      @socket.on "CHANNEL_EXECUTE_COMPLETE #{app_name} #{app_arg}", (res) ->
        cb.apply res
    @execute_uuid uuid,app_name,app_arg

  # Hangup a call
