   register_callback: (event,cb) ->
     @socket.on event, (res) =>
       @socket.removeAllListeners event
-      cb.apply res
+      cb res
 
   # A generic way of sending commands to FreeSwitch.
   #

  # 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

  socket.on 'end',  ()     ->  parser.on_end()

  # Make the command responses somewhat unique.
  socket.on 'CHANNEL_EXECUTE_COMPLETE', (res) ->
    application = @body['Application']
    application_data = @body['Application-Data']
    socket.emit "#{event_name} #{application} #{application_data}", res

  parser.process = (headers,body) ->
    if exports.debug
