I have a rails application that i'am trying to get real time events from the my asterisk through AMI.
I successfully created a script to originate calls from the adhearsion source code without creating a new adhearsion project.
I created a class extending the adhearsion's ManagerInterface class and overriding the event_message_received method. From the Rails CLI if someone calls and i press the enter 2 or 3 times i get the event but i have to intervene to get it.
Here is my code :
class Astercall < Adhearsion::VoIP::Asterisk::Manager::ManagerInterface
def initialize
super(:host => "host", :username => "username", :password => "password", :events => true)
connect!
end
def self.click_call(number, exten, name)
# asterisk = connect()
originate(:channel => "SIP/#{exten}",
:context => "from-internal",
:exten => number,
:priority => "1",
:caller_id => "Calling #{name}")
end
def event_message_received(event)
if(event.kind_of? Adhearsion::VoIP::Asterisk::Manager::ManagerInterfaceEvent )
puts event.inspect
end
end
end
Do i have to run a background process to do that. If i do, how am i going to do it????
Thanks in advance