Class: Adhearsion::VoIP::Asterisk::Commands::QueueProxy::AgentProxy
- Defined in:
- lib/adhearsion/voip/asterisk/commands.rb
Constant Summary collapse
- SUPPORTED_METADATA_NAMES =
%w[status password name mohclass exten channel]
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#interface ⇒ Object
readonly
Returns the value of attribute interface.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
-
#queue_name ⇒ Object
readonly
Returns the value of attribute queue_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(interface, proxy) ⇒ AgentProxy
constructor
A new instance of AgentProxy.
-
#logged_in? ⇒ Boolean
Returns true/false depending on whether this agent is logged in.
-
#pause!(options = {}) ⇒ Object
Pauses the given agent for this queue only.
- #remove! ⇒ Object
-
#unpause!(options = {}) ⇒ Object
Pauses the given agent for this queue only.
Constructor Details
#initialize(interface, proxy) ⇒ AgentProxy
Returns a new instance of AgentProxy.
1465 1466 1467 1468 1469 1470 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1465 def initialize(interface, proxy) @interface = interface @id = self.class.id_from_agent_channel interface @proxy = proxy @queue_name = proxy.name end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
1464 1465 1466 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1464 def id @id end |
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
1464 1465 1466 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1464 def interface @interface end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
1464 1465 1466 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1464 def proxy @proxy end |
#queue_name ⇒ Object (readonly)
Returns the value of attribute queue_name.
1464 1465 1466 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1464 def queue_name @queue_name end |
Class Method Details
.id_from_agent_channel(id) ⇒ Object
1458 1459 1460 1461 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1458 def id_from_agent_channel(id) id = id.to_s id.starts_with?('Agent/') ? id[%r[^Agent/(.+)$],1] : id end |
Instance Method Details
#logged_in? ⇒ Boolean
Returns true/false depending on whether this agent is logged in.
1515 1516 1517 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1515 def logged_in? status == 'LOGGEDIN' end |
#pause!(options = {}) ⇒ Object
Pauses the given agent for this queue only. If you wish to pause this agent for all queues, pass in :everywhere => true. Returns true if the agent was successfully paused and false if the agent was not found.
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1487 def pause!(={}) everywhere = .delete(:everywhere) args = [(everywhere ? nil : queue_name), interface] proxy.environment.execute('PauseQueueMember', *args) case proxy.environment.variable("PQMSTATUS") when "PAUSED" then true when "NOTFOUND" then false else raise "Unrecognized PQMSTATUS value!" end end |
#remove! ⇒ Object
1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1472 def remove! proxy.environment.execute 'RemoveQueueMember', queue_name, interface case proxy.environment.variable("RQMSTATUS") when "REMOVED" then true when "NOTINQUEUE" then false when "NOSUCHQUEUE" raise QueueDoesNotExistError.new(queue_name) else raise "Unrecognized RQMSTATUS variable!" end end |
#unpause!(options = {}) ⇒ Object
Pauses the given agent for this queue only. If you wish to pause this agent for all queues, pass in :everywhere => true. Returns true if the agent was successfully paused and false if the agent was not found.
1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1502 def unpause!(={}) everywhere = .delete(:everywhere) args = [(everywhere ? nil : queue_name), interface] proxy.environment.execute('UnpauseQueueMember', *args) case proxy.environment.variable("UPQMSTATUS") when "UNPAUSED" then true when "NOTFOUND" then false else raise "Unrecognized UPQMSTATUS value!" end end |