Skip to content

Instantly share code, notes, and snippets.

@silvioq
Created August 17, 2011 20:01
Show Gist options
  • Save silvioq/1152454 to your computer and use it in GitHub Desktop.
Save silvioq/1152454 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/ruby
## This shows how to use the Server and Client classes together, without using Server to create a separate proxy server.
require 'rubygems'
require 'rami'
include Rami
def print_results(t)
if t.size > 0
t.each do |array|
array.each {|key,value| puts "#{key}: #{value}"}
end
end
puts "\n\n"
end
server = Server.new({'host' => 'localhost', 'username' => 'asterisk', 'secret' => 'secret'})
server.console =1
server.event_cache = 100
server.run
client = Client.new(server)
client.timeout = 10
t = client.ping
print_results(t)
t = client.mailbox_count(1002)
print_results(t)
t = client.get_events
print_results(t)
client.stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment