-
Notifications
You must be signed in to change notification settings - Fork 3
/
events.rb
executable file
·43 lines (41 loc) · 1.2 KB
/
events.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
##
# In this file you can define callbacks for different aspects of the framework. Below is an example:
##
#
# events.asterisk.before_call.each do |call|
# # This simply logs the extension for all calls going through this Adhearsion app.
# extension = call.variables[:extension]
# ahn_log "Got a new call with extension #{extension}"
# end
#
##
# Asterisk Manager Interface example:
#
# events.asterisk.manager_interface.each do |event|
# ahn_log.events event.inspect
# end
#
# This assumes you gave :events => true to the config.asterisk.enable_ami method in config/startup.rb
#
##
# Here is a list of the events included by default:
#
# - events.exception
# - events.asterisk.manager_interface
# - events.after_initialized
# - events.shutdown
# - events.asterisk.before_call
# - events.asterisk.failed_call
# - events.asterisk.hungup_call
#
#
# Note: events are mostly for components to register and expose to you.
##
events.exception.each do |e|
ahn_log.error "#{e.class}: #{e.message}"
ahn_log.error e.backtrace.join("\n\t")
end
events.asterisk.failed_call.each do |e|
tropo_tag = JSON.parse(e.tropo_headers)["tropo_tag"]
Resque.enqueue FailedJob, { :id => tropo_tag, :failed_reason => e.failed_reason }
end