Adhearsion includes a flexible event handling system, and events may be handled either globally or per-call:
In order to handle events global to the whole system, one must declare a (potentially-guarded) handler. There are two methods by which this may be achieved:
config/adhearsion.rb:
Adhearsion::Events.draw do
# eg. Handling Punchblock events
# punchblock do |event|
# ...
# end
#
# eg Handling PeerStatus AMI events
# ami name: 'PeerStatus' do |event|
# ...
# end
endor, elsewhere in your code:
# eg. Handling Punchblock events
# Adhearsion::Events.punchblock do |event|
# ...
# endThe available categories of events are currently:
class MyController < Adhearsion::CallController
before_call do
call.register_event_handler do |event|
...
end
end
endThe available guards are the same as those which apply in the Routing DSL, and are documented on the has-guarded-handlers wesbite.