Class: RubyAsterisk::AMI
- Inherits:
-
Object
- Object
- RubyAsterisk::AMI
- Defined in:
- lib/ruby-asterisk.rb
Instance Attribute Summary collapse
-
#connected ⇒ Object
Returns the value of attribute connected.
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
- #channels ⇒ Object
- #command(command) ⇒ Object
- #connect ⇒ Object
- #core_show_channels ⇒ Object
- #disconnect ⇒ Object
- #event_mask(event_mask = "off") ⇒ Object
- #extension_state(exten, context, action_id = nil) ⇒ Object
-
#initialize(host, port) ⇒ AMI
constructor
A new instance of AMI.
- #login(username, password) ⇒ Object
- #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
- #ping ⇒ Object
- #queue_add(queue, exten, penalty = 2, paused = false, member_name) ⇒ Object
- #queue_pause(interface, paused, queue, reason = 'none') ⇒ Object
- #queue_remove(queue, exten) ⇒ Object
- #queue_status ⇒ Object
- #queue_summary(queue) ⇒ Object
- #queues ⇒ Object
- #redirect(caller, context, callee, priority, variable = nil) ⇒ Object
- #sip_peers ⇒ Object
- #skinny_devices ⇒ Object
- #skinny_lines ⇒ Object
- #status(channel = nil, action_id = nil) ⇒ Object
Constructor Details
#initialize(host, port) ⇒ AMI
Returns a new instance of AMI.
11 12 13 14 15 16 |
# File 'lib/ruby-asterisk.rb', line 11 def initialize(host,port) self.host = host.to_s self.port = port.to_i self.connected = false @session = nil end |
Instance Attribute Details
#connected ⇒ Object
Returns the value of attribute connected.
9 10 11 |
# File 'lib/ruby-asterisk.rb', line 9 def connected @connected end |
#host ⇒ Object
Returns the value of attribute host.
9 10 11 |
# File 'lib/ruby-asterisk.rb', line 9 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
9 10 11 |
# File 'lib/ruby-asterisk.rb', line 9 def port @port end |
Instance Method Details
#channels ⇒ Object
80 81 82 |
# File 'lib/ruby-asterisk.rb', line 80 def channels execute "Command", { "Command" => "show channels" } end |
#command(command) ⇒ Object
44 45 46 |
# File 'lib/ruby-asterisk.rb', line 44 def command(command) execute "Command", {"Command" => command} end |
#connect ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/ruby-asterisk.rb', line 18 def connect begin @session = Net::Telnet::new("Host" => self.host,"Port" => self.port) self.connected = true rescue Exception => ex false end end |
#core_show_channels ⇒ Object
48 49 50 |
# File 'lib/ruby-asterisk.rb', line 48 def core_show_channels execute "CoreShowChannels" end |
#disconnect ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruby-asterisk.rb', line 27 def disconnect begin @session.close if self.connected @session = nil self.connected = false true rescue Exception => ex puts ex false end end |
#event_mask(event_mask = "off") ⇒ Object
128 129 130 |
# File 'lib/ruby-asterisk.rb', line 128 def event_mask(event_mask="off") execute "Events", {"EventMask" => event_mask} end |
#extension_state(exten, context, action_id = nil) ⇒ Object
60 61 62 |
# File 'lib/ruby-asterisk.rb', line 60 def extension_state(exten, context, action_id=nil) execute "ExtensionState", {"Exten" => exten, "Context" => context, "ActionID" => action_id} end |
#login(username, password) ⇒ Object
39 40 41 42 |
# File 'lib/ruby-asterisk.rb', line 39 def login(username,password) self.connect unless self.connected execute "Login", {"Username" => username, "Secret" => password, "Event" => "On"} end |
#mailbox_count(exten, context = "default") ⇒ Object
116 117 118 |
# File 'lib/ruby-asterisk.rb', line 116 def mailbox_count(exten, context="default") execute "MailboxCount", {"Mailbox" => "#{exten}@#{context}"} end |
#mailbox_status(exten, context = "default") ⇒ Object
112 113 114 |
# File 'lib/ruby-asterisk.rb', line 112 def mailbox_status(exten, context="default") execute "MailboxStatus", {"Mailbox" => "#{exten}@#{context}"} end |
#meet_me_list ⇒ Object
52 53 54 |
# File 'lib/ruby-asterisk.rb', line 52 def meet_me_list execute "MeetMeList" end |
#originate(caller, context, callee, priority, variable = nil) ⇒ Object
76 77 78 |
# File 'lib/ruby-asterisk.rb', line 76 def originate(caller,context,callee,priority,variable=nil) execute "Originate", {"Channel" => caller, "Context" => context, "Exten" => callee, "Priority" => priority, "Callerid" => caller, "Timeout" => "30000", "Variable" => variable } end |
#parked_calls ⇒ Object
56 57 58 |
# File 'lib/ruby-asterisk.rb', line 56 def parked_calls execute "ParkedCalls" end |
#ping ⇒ Object
124 125 126 |
# File 'lib/ruby-asterisk.rb', line 124 def ping execute "Ping" end |
#queue_add(queue, exten, penalty = 2, paused = false, member_name) ⇒ Object
92 93 94 |
# File 'lib/ruby-asterisk.rb', line 92 def queue_add(queue, exten, penalty=2, paused=false, member_name) execute "QueueAdd", {"Queue" => queue, "Interface" => exten, "Penalty" => penalty, "Paused" => paused, "MemberName" => member_name} end |
#queue_pause(interface, paused, queue, reason = 'none') ⇒ Object
96 97 98 |
# File 'lib/ruby-asterisk.rb', line 96 def queue_pause(queue, exten) execute "QueuePause", {"Interface" => exten, "Paused" => paused} end |
#queue_remove(queue, exten) ⇒ Object
100 101 102 |
# File 'lib/ruby-asterisk.rb', line 100 def queue_remove(queue, exten) execute "QueueRemove", {"Queue" => queue, "Interface" => exten} end |
#queue_status ⇒ Object
104 105 106 |
# File 'lib/ruby-asterisk.rb', line 104 def queue_status execute "QueueStatus" end |
#queue_summary(queue) ⇒ Object
108 109 110 |
# File 'lib/ruby-asterisk.rb', line 108 def queue_summary(queue) execute "QueueSummary", {"Queue" => queue} end |
#queues ⇒ Object
88 89 90 |
# File 'lib/ruby-asterisk.rb', line 88 def queues execute "Queues", {} end |
#redirect(caller, context, callee, priority, variable = nil) ⇒ Object
84 85 86 |
# File 'lib/ruby-asterisk.rb', line 84 def redirect(caller,context,callee,priority,variable=nil) execute "Redirect", {"Channel" => caller, "Context" => context, "Exten" => callee, "Priority" => priority, "Callerid" => caller, "Timeout" => "30000", "Variable" => variable} end |
#sip_peers ⇒ Object
132 133 134 |
# File 'lib/ruby-asterisk.rb', line 132 def sip_peers execute "SIPpeers" end |
#skinny_devices ⇒ Object
64 65 66 |
# File 'lib/ruby-asterisk.rb', line 64 def skinny_devices execute "SKINNYdevices" end |
#skinny_lines ⇒ Object
68 69 70 |
# File 'lib/ruby-asterisk.rb', line 68 def skinny_lines execute "SKINNYlines" end |
#status(channel = nil, action_id = nil) ⇒ Object
72 73 74 |
# File 'lib/ruby-asterisk.rb', line 72 def status(channel=nil,action_id=nil) execute "Status", {"Channel" => channel, "ActionID" => action_id} end |