Class: Adhearsion::Asterisk::QueueProxy
- Inherits:
-
Object
- Object
- Adhearsion::Asterisk::QueueProxy
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/adhearsion/asterisk/queue_proxy.rb,
lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb,
lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb
Defined Under Namespace
Classes: AgentProxy, QueueAgentsListProxy
Instance Attribute Summary (collapse)
-
- (Object) environment
readonly
Returns the value of attribute environment.
-
- (Object) name
readonly
Returns the value of attribute name.
Class Method Summary (collapse)
Instance Method Summary (collapse)
-
- (QueueAgentsListProxy) agents(options = {})
Get the agents associated with a queue.
-
- (Boolean) any?
Check whether any calls are waiting in the queue.
-
- (Boolean) empty?
Check whether the waiting count is zero.
-
- (Boolean) exists?
Check whether a queue exists/is defined in Asterisk.
-
- (QueueProxy) initialize(name, environment)
constructor
A new instance of QueueProxy.
-
- (Object) join!(options = {})
Makes the current channel join the queue.
-
- (Integer) waiting_count
Check how many channels are waiting in the queue.
Constructor Details
- (QueueProxy) initialize(name, environment)
A new instance of QueueProxy
59 60 61 |
# File 'lib/adhearsion/asterisk/queue_proxy.rb', line 59 def initialize(name, environment) @name, @environment = name, environment end |
Instance Attribute Details
- (Object) environment (readonly)
Returns the value of attribute environment
57 58 59 |
# File 'lib/adhearsion/asterisk/queue_proxy.rb', line 57 def environment @environment end |
- (Object) name (readonly)
Returns the value of attribute name
57 58 59 |
# File 'lib/adhearsion/asterisk/queue_proxy.rb', line 57 def name @name end |
Class Method Details
+ (Object) format_join_hash_key_arguments(options)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/adhearsion/asterisk/queue_proxy.rb', line 11 def format_join_hash_key_arguments() bad_argument = lambda do |(key, value)| raise ArgumentError, "Unrecognize value for #{key.inspect} -- #{value.inspect}" end # Direct Queue() arguments: timeout = .delete :timeout announcement = .delete :announce # Terse single-character options ring_style = .delete :play allow_hangup = .delete :allow_hangup allow_transfer = .delete :allow_transfer agi = .delete :agi raise ArgumentError, "Unrecognized args to join!: #{.inspect}" if .any? ring_style = case ring_style when :ringing then 'r' when :music then '' when nil else bad_argument[:play => ring_style] end.to_s allow_hangup = case allow_hangup when :caller then 'H' when :agent then 'h' when :everyone then 'Hh' when nil else bad_argument[:allow_hangup => allow_hangup] end.to_s allow_transfer = case allow_transfer when :caller then 'T' when :agent then 't' when :everyone then 'Tt' when nil else bad_argument[:allow_transfer => allow_transfer] end.to_s = ring_style + allow_transfer + allow_hangup [, '', announcement, timeout, agi].map(&:to_s) end |
Instance Method Details
- (QueueAgentsListProxy) agents(options = {})
Get the agents associated with a queue
107 108 109 110 111 112 113 114 115 |
# File 'lib/adhearsion/asterisk/queue_proxy.rb', line 107 def agents( = {}) cached = .has_key?(:cache) ? .delete(:cache) : true raise ArgumentError, "Unrecognized arguments to #agents: #{.inspect}" if .keys.any? if cached @cached_proxy ||= QueueAgentsListProxy.new(self, true) else @uncached_proxy ||= QueueAgentsListProxy.new(self, false) end end |
- (Boolean) any?
Check whether any calls are waiting in the queue
133 134 135 |
# File 'lib/adhearsion/asterisk/queue_proxy.rb', line 133 def any? waiting_count > 0 end |
- (Boolean) empty?
Check whether the waiting count is zero
127 128 129 |
# File 'lib/adhearsion/asterisk/queue_proxy.rb', line 127 def empty? waiting_count == 0 end |
- (Boolean) exists?
Check whether a queue exists/is defined in Asterisk
139 140 141 142 |
# File 'lib/adhearsion/asterisk/queue_proxy.rb', line 139 def exists? environment.execute('RemoveQueueMember', name, 'SIP/AdhearsionQueueExistenceCheck') environment.get_variable("RQMSTATUS") != 'NOSUCHQUEUE' end |
- (Object) join!(options = {})
Makes the current channel join the queue.
@example
queue('sales').join!
@example
queue('sales').join! :timeout => 1.minute
@example
queue('sales').join! :play => :music
@example
queue('sales').join! :play => :ringing
@example
queue('sales').join! :announce => "custom/special-queue-announcement"
@example
queue('sales').join! :allow_transfer => :caller
@example
queue('sales').join! :allow_transfer => :agent
@example
queue('sales').join! :allow_hangup => :caller
@example
queue('sales').join! :allow_hangup => :agent
@example
queue('sales').join! :allow_hangup => :everyone
@example
queue('sales').join! :agi => 'agi://localhost/sales_queue_callback'
@example
queue('sales').join! :allow_transfer => :agent, :timeout => 30.seconds,
98 99 100 101 |
# File 'lib/adhearsion/asterisk/queue_proxy.rb', line 98 def join!( = {}) environment.execute("queue", name, *self.class.format_join_hash_key_arguments()) normalize_queue_status_variable environment.get_variable("QUEUESTATUS") end |
- (Integer) waiting_count
Check how many channels are waiting in the queue
120 121 122 123 |
# File 'lib/adhearsion/asterisk/queue_proxy.rb', line 120 def waiting_count raise QueueDoesNotExistError.new(name) unless exists? environment.get_variable("QUEUE_WAITING_COUNT(#{name})").to_i end |