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.
1345 1346 1347 1348 1349 1350 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1345 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.
1344 1345 1346 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1344 def id @id end |
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
1344 1345 1346 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1344 def interface @interface end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
1344 1345 1346 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1344 def proxy @proxy end |
#queue_name ⇒ Object (readonly)
Returns the value of attribute queue_name.
1344 1345 1346 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1344 def queue_name @queue_name end |
Class Method Details
.id_from_agent_channel(id) ⇒ Object
1338 1339 1340 1341 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1338 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.
1395 1396 1397 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1395 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.
1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1367 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
1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1352 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.
1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1382 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 |