Class: Adhearsion::VoIP::Asterisk::Commands::QueueProxy::QueueAgentsListProxy
- Inherits:
-
Object
- Object
- Adhearsion::VoIP::Asterisk::Commands::QueueProxy::QueueAgentsListProxy
- Includes:
- Enumerable
- Defined in:
- lib/adhearsion/voip/asterisk/commands.rb
Instance Attribute Summary collapse
-
#agents ⇒ Object
readonly
Returns the value of attribute agents.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
Instance Method Summary collapse
- #cached? ⇒ Boolean
- #count ⇒ Object (also: #size, #length)
- #each(&block) ⇒ Object
- #first ⇒ Object
-
#initialize(proxy, cached = false) ⇒ QueueAgentsListProxy
constructor
A new instance of QueueAgentsListProxy.
- #last ⇒ Object
-
#login!(*args) ⇒ Object
Logs a pre-defined agent into this queue and waits for calls.
-
#logout! ⇒ Object
Removes the current channel from this queue.
-
#new(*args) ⇒ Object
:name value will be viewable in the queue_log :penalty is the penalty assigned to this agent for answering calls on this queue.
- #to_a ⇒ Object
Constructor Details
#initialize(proxy, cached = false) ⇒ QueueAgentsListProxy
Returns a new instance of QueueAgentsListProxy.
1329 1330 1331 1332 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1329 def initialize(proxy, cached=false) @proxy = proxy @cached = cached end |
Instance Attribute Details
#agents ⇒ Object (readonly)
Returns the value of attribute agents.
1328 1329 1330 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1328 def agents @agents end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
1328 1329 1330 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1328 def proxy @proxy end |
Instance Method Details
#cached? ⇒ Boolean
1424 1425 1426 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1424 def cached? @cached end |
#count ⇒ Object Also known as: size, length
1334 1335 1336 1337 1338 1339 1340 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1334 def count if cached? && @cached_count @cached_count else @cached_count = proxy.environment.variable("QUEUE_MEMBER_COUNT(#{proxy.name})").to_i end end |
#each(&block) ⇒ Object
1409 1410 1411 1412 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1409 def each(&block) check_agent_cache! agents.each(&block) end |
#first ⇒ Object
1414 1415 1416 1417 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1414 def first check_agent_cache! agents.first end |
#last ⇒ Object
1419 1420 1421 1422 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1419 def last check_agent_cache! agents.last end |
#login!(*args) ⇒ Object
Logs a pre-defined agent into this queue and waits for calls. Pass in :silent => true to stop the message which says “Agent logged in”.
1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1383 def login!(*args) = args.last.kind_of?(Hash) ? args.pop : {} silent = .delete(:silent).equal?(false) ? '' : 's' id = args.shift id &&= AgentProxy.id_from_agent_channel(id) raise ArgumentError, "Unrecognized Hash options to login(): #{.inspect}" if .any? raise ArgumentError, "Unrecognized argument to login(): #{args.inspect}" if args.any? proxy.environment.execute('AgentLogin', id, silent) end |
#logout! ⇒ Object
Removes the current channel from this queue
1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1396 def logout! # TODO: DRY this up. Repeated in the AgentProxy... proxy.environment.execute 'RemoveQueueMember', proxy.name case proxy.environment.variable("RQMSTATUS") when "REMOVED" then true when "NOTINQUEUE" then false when "NOSUCHQUEUE" raise QueueDoesNotExistError.new(proxy.name) else raise "Unrecognized RQMSTATUS variable!" end end |
#new(*args) ⇒ Object
:name value will be viewable in the queue_log :penalty is the penalty assigned to this agent for answering calls on this queue
1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1347 def new(*args) = args.last.kind_of?(Hash) ? args.pop : {} interface = args.shift raise ArgumentError, "You must specify an interface to add." if interface.nil? raise ArgumentError, "You may only supply an interface and a Hash argument!" if args.any? penalty = .delete(:penalty) || '' name = .delete(:name) || '' state_interface = .delete(:state_interface) || '' raise ArgumentError, "Unrecognized argument(s): #{.inspect}" if .any? proxy.environment.execute("AddQueueMember", proxy.name, interface, penalty, '', name, state_interface) added = case proxy.environment.variable("AQMSTATUS") when "ADDED" then true when "MEMBERALREADY" then false when "NOSUCHQUEUE" then raise QueueDoesNotExistError.new(proxy.name) else raise "UNRECOGNIZED AQMSTATUS VALUE!" end if added check_agent_cache! AgentProxy.new(interface, proxy).tap do |agent_proxy| @agents << agent_proxy end else false end end |
#to_a ⇒ Object
1428 1429 1430 1431 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1428 def to_a check_agent_cache! @agents end |