Skip to content

Instantly share code, notes, and snippets.

@wwalker
Created May 27, 2009 17:51
Show Gist options
  • Save wwalker/118777 to your computer and use it in GitHub Desktop.
Save wwalker/118777 to your computer and use it in GitHub Desktop.
methods_for :rpc do
def async_call_into_context(channel, context, options={})
ahn_log.info "async_call_into_context channel: <#{channel}>"
ahn_log.info "async_call_into_context channel: <#{context}>"
ahn_log.info "async_call_into_context channel: <#{options.inspect}>"
#action = send_action_asynchronously "Login", "Username" => @username, "Secret" => @password, "Events" => "Off"
options[:variable] = options[:variables].map {|pair| pair.join('=')}.join('|')
action = VoIP::Asterisk.manager_interface.send_action_asynchronously "Originate", options.merge("Context" => context, "Channel" => channel)
response = action.response
if response.kind_of? VoIP::Asterisk::Manager::ManagerInterfaceError
ahn_log.error "AMI ERROR! #{response.message}"
else
ahn_log.info "Originate response:"
ahn_log.debug response.inspect
pp response
response
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment