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
1218 1219 1220 1221 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1218 def initialize(proxy, cached=false) @proxy = proxy @cached = cached end |
Instance Attribute Details
#agents ⇒ Object (readonly)
Returns the value of attribute agents.
1217 1218 1219 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1217 def agents @agents end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
1217 1218 1219 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1217 def proxy @proxy end |
Instance Method Details
#cached? ⇒ Boolean
1304 1305 1306 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1304 def cached? @cached end |
#count ⇒ Object Also known as: size, length
1223 1224 1225 1226 1227 1228 1229 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1223 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
1289 1290 1291 1292 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1289 def each(&block) check_agent_cache! agents.each(&block) end |
#first ⇒ Object
1294 1295 1296 1297 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1294 def first check_agent_cache! agents.first end |
#last ⇒ Object
1299 1300 1301 1302 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1299 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”.
1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1263 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
1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1276 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
1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1236 def new(*args) = args.last.kind_of?(Hash) ? args.pop : {} interface = args.shift || '' raise ArgumentError, "You may only supply an interface and a Hash argument!" if args.any? penalty = .delete(:penalty) || '' name = .delete(:name) || '' raise ArgumentError, "Unrecognized argument(s): #{.inspect}" if .any? proxy.environment.execute("AddQueueMember", proxy.name, interface, penalty, '', name) 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 # TODO: THIS SHOULD RETURN AN AGENT INSTANCE end |
#to_a ⇒ Object
1308 1309 1310 1311 |
# File 'lib/adhearsion/voip/asterisk/commands.rb', line 1308 def to_a check_agent_cache! @agents end |