Class: Asterisk::AMI
- Inherits:
-
Object
- Object
- Asterisk::AMI
- Defined in:
- lib/ami.rb
Instance Method Summary collapse
- #channels ⇒ Object
- #command(command) ⇒ Object
- #connect ⇒ Object
- #core_show_channels ⇒ Object
- #disconnect ⇒ Object
- #extension_state(exten, context) ⇒ Object
-
#initialize(username, password, host = "localhost", port = 5038) ⇒ AMI
constructor
A new instance of AMI.
- #mailbox_count(exten, context = "default") ⇒ Object
- #mailbox_status(exten, context = "default") ⇒ Object
- #meet_me_list ⇒ Object
- #originate(caller, context, callee, priority, variable = nil) ⇒ Object
- #parked_calls ⇒ Object
- #queue_add(queue, exten, penalty = 2, paused = false, member_name) ⇒ Object
- #queue_pause(queue, exten) ⇒ Object
- #queue_remove(queue, exten) ⇒ Object
- #queue_status ⇒ Object
- #queue_summary(queue) ⇒ Object
- #queues ⇒ Object
- #redirect(caller, context, callee, priority, variable = nil) ⇒ Object
Constructor Details
#initialize(username, password, host = "localhost", port = 5038) ⇒ AMI
Returns a new instance of AMI.
10 11 12 13 |
# File 'lib/ami.rb', line 10 def initialize(username, password, host="localhost", port=5038) @connection = Asterisk::Connection.new(username, password, host, port) @connected = false end |
Instance Method Details
#channels ⇒ Object
59 60 61 |
# File 'lib/ami.rb', line 59 def channels Asterisk::Action.new("Command", { "Command" => "show channels" }).send(@connection) end |
#command(command) ⇒ Object
35 36 37 |
# File 'lib/ami.rb', line 35 def command(command) Asterisk::Action.new("Command", {"Command" => command}).send(@connection) end |
#connect ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/ami.rb', line 15 def connect begin @connection.connect self.connected = true rescue Exception => ex false end end |
#core_show_channels ⇒ Object
39 40 41 |
# File 'lib/ami.rb', line 39 def core_show_channels Asterisk::Action.new("CoreShowChannels").send(@connection) end |
#disconnect ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ami.rb', line 24 def disconnect begin @connection.disconnect if self.connected self.connected = false true rescue Exception => ex puts ex false end end |
#extension_state(exten, context) ⇒ Object
51 52 53 |
# File 'lib/ami.rb', line 51 def extension_state(exten,context) Asterisk::Action.new("ExtensionState", {"Exten" => exten, "Context" => context}).send(@connection) end |
#mailbox_count(exten, context = "default") ⇒ Object
95 96 97 |
# File 'lib/ami.rb', line 95 def mailbox_count(exten, context="default") Asterisk::Action.new("MailboxCount", {"Mailbox" => "#{exten}@#{context}"}).send(@connection) end |
#mailbox_status(exten, context = "default") ⇒ Object
91 92 93 |
# File 'lib/ami.rb', line 91 def mailbox_status(exten, context="default") Asterisk::Action.new("MailboxStatus", {"Mailbox" => "#{exten}@#{context}"}).send(@connection) end |
#meet_me_list ⇒ Object
43 44 45 |
# File 'lib/ami.rb', line 43 def meet_me_list Asterisk::Action.new("MeetMeList").send(@connection) end |
#originate(caller, context, callee, priority, variable = nil) ⇒ Object
55 56 57 |
# File 'lib/ami.rb', line 55 def originate(caller,context,callee,priority,variable=nil) Asterisk::Action.new("Originate", {"Channel" => caller, "Context" => context, "Exten" => callee, "Priority" => priority, "Callerid" => caller, "Timeout" => "30000", "Variable" => variable }).send(@connection) end |
#parked_calls ⇒ Object
47 48 49 |
# File 'lib/ami.rb', line 47 def parked_calls Asterisk::Action.new("ParkedCalls").send(@connection) end |
#queue_add(queue, exten, penalty = 2, paused = false, member_name) ⇒ Object
71 72 73 |
# File 'lib/ami.rb', line 71 def queue_add(queue, exten, penalty=2, paused=false, member_name) Asterisk::Action.new("QueueAdd", {"Queue" => queue, "Interface" => exten, "Penalty" => penalty, "Paused" => paused, "MemberName" => member_name}).send(@connection) end |
#queue_pause(queue, exten) ⇒ Object
75 76 77 |
# File 'lib/ami.rb', line 75 def queue_pause(queue, exten) Asterisk::Action.new("QueuePause", {"Interface" => exten, "Paused" => paused}).send(@connection) end |
#queue_remove(queue, exten) ⇒ Object
79 80 81 |
# File 'lib/ami.rb', line 79 def queue_remove(queue, exten) Asterisk::Action.new("QueueRemove", {"Queue" => queue, "Interface" => exten}).send(@connection) end |
#queue_status ⇒ Object
83 84 85 |
# File 'lib/ami.rb', line 83 def queue_status Asterisk::Action.new("QueueStatus").send(@connection) end |
#queue_summary(queue) ⇒ Object
87 88 89 |
# File 'lib/ami.rb', line 87 def queue_summary(queue) Asterisk::Action.new("QueueSummary", {"Queue" => queue}).send(@connection) end |
#queues ⇒ Object
67 68 69 |
# File 'lib/ami.rb', line 67 def queues Asterisk::Action.new("Queues").send(@connection) end |
#redirect(caller, context, callee, priority, variable = nil) ⇒ Object
63 64 65 |
# File 'lib/ami.rb', line 63 def redirect(caller,context,callee,priority,variable=nil) Asterisk::Action.new("Redirect", {"Channel" => caller, "Context" => context, "Exten" => callee, "Priority" => priority, "Callerid" => caller, "Timeout" => "30000", "Variable" => variable}).send(@connection) end |