Class: Adhearsion::Asterisk::QueueProxy::AgentProxy
- Inherits:
-
Object
- Object
- Adhearsion::Asterisk::QueueProxy::AgentProxy
- Defined in:
- lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb
Constant Summary
- SUPPORTED_METADATA_NAMES =
%w[status password name mohclass exten channel]
Instance Attribute Summary (collapse)
-
- (Object) id
readonly
Returns the value of attribute id.
-
- (Object) interface
readonly
Returns the value of attribute interface.
-
- (Object) proxy
readonly
Returns the value of attribute proxy.
-
- (Object) queue_name
readonly
Returns the value of attribute queue_name.
Class Method Summary (collapse)
Instance Method Summary (collapse)
-
- (AgentProxy) initialize(interface, proxy)
constructor
A new instance of AgentProxy.
-
- (Boolean) logged_in?
Returns true/false depending on whether this agent is logged in.
-
- (Object) pause!(options = {})
Pauses the given agent for this queue only.
- - (Object) remove!
-
- (Object) unpause!(options = {})
Pauses the given agent for this queue only.
Constructor Details
- (AgentProxy) initialize(interface, proxy)
A new instance of AgentProxy
16 17 18 19 20 |
# File 'lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb', line 16 def initialize(interface, proxy) @interface, @proxy = interface, proxy @id = self.class.id_from_agent_channel interface @queue_name = proxy.name end |
Instance Attribute Details
- (Object) id (readonly)
Returns the value of attribute id
15 16 17 |
# File 'lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb', line 15 def id @id end |
- (Object) interface (readonly)
Returns the value of attribute interface
15 16 17 |
# File 'lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb', line 15 def interface @interface end |
- (Object) proxy (readonly)
Returns the value of attribute proxy
15 16 17 |
# File 'lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb', line 15 def proxy @proxy end |
- (Object) queue_name (readonly)
Returns the value of attribute queue_name
15 16 17 |
# File 'lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb', line 15 def queue_name @queue_name end |
Class Method Details
+ (Object) id_from_agent_channel(id)
9 10 11 12 |
# File 'lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb', line 9 def id_from_agent_channel(id) id = id.to_s id.starts_with?('Agent/') ? id[%r[^Agent/(.+)$],1] : id end |
Instance Method Details
- (Boolean) logged_in?
Returns true/false depending on whether this agent is logged in.
63 64 65 |
# File 'lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb', line 63 def logged_in? status == 'LOGGEDIN' end |
- (Object) pause!(options = {})
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.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb', line 37 def pause!( = {}) args = [(.delete(:everywhere) ? nil : queue_name), interface] proxy.environment.execute 'PauseQueueMember', *args case proxy.environment.get_variable("PQMSTATUS") when "PAUSED" then true when "NOTFOUND" then false else raise "Unrecognized PQMSTATUS value!" end end |
- (Object) remove!
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb', line 22 def remove! proxy.environment.execute 'RemoveQueueMember', queue_name, interface case proxy.environment.get_variable("RQMSTATUS") when "REMOVED" then true when "NOTINQUEUE" then false when "NOSUCHQUEUE" raise QueueDoesNotExistError.new(queue_name) else raise "Unrecognized RQMSTATUS variable!" end end |
- (Object) unpause!(options = {})
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.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/adhearsion/asterisk/queue_proxy/agent_proxy.rb', line 51 def unpause!( = {}) args = [(.delete(:everywhere) ? nil : queue_name), interface] proxy.environment.execute 'UnpauseQueueMember', *args case proxy.environment.get_variable("UPQMSTATUS") when "UNPAUSED" then true when "NOTFOUND" then false else raise "Unrecognized UPQMSTATUS value!" end end |