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.
1394 1395 1396 1397 1398 1399 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1394 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.
1393 1394 1395 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1393 def id @id end |
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
1393 1394 1395 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1393 def interface @interface end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
1393 1394 1395 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1393 def proxy @proxy end |
#queue_name ⇒ Object (readonly)
Returns the value of attribute queue_name.
1393 1394 1395 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1393 def queue_name @queue_name end |
Class Method Details
.id_from_agent_channel(id) ⇒ Object
1387 1388 1389 1390 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1387 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.
1444 1445 1446 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1444 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.
1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1416 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
1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1401 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.
1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1431 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 |