mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-19 11:13:09 +00:00
app_queue: Support an 'agent available' hint
Sets INUSE when no free agents, NOT_INUSE when an agent is free. modifes handle_statechange() scan members loop to scan for a free agent and updates the Queue:queuename_avial devstate. Previously exited early if the member was found in the queue. Now Exits later when both a member was found, and a free agent was found. alecdavis (license 585) Reported by: Alec Davis Tested by: alecdavis Review: https://reviewboard.asterisk.org/r/2121/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@373188 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
7
CHANGES
7
CHANGES
@@ -23,6 +23,13 @@ Logging
|
||||
individual queue, the PAUSEALL/UNPAUSEALL event will only be logged if at
|
||||
least one member of any queue exists for that interface.
|
||||
|
||||
Queue
|
||||
-------------------
|
||||
* Add queue available hint. exten => 8501,hint,Queue:markq_avail
|
||||
Note: the suffix '_avail' after the queuename.
|
||||
Reports 'InUse' for no logged in agents or no free agents.
|
||||
Reports 'Idle' when an agent is free.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
--- Functionality changes from Asterisk 10 to Asterisk 11 --------------------
|
||||
------------------------------------------------------------------------------
|
||||
|
@@ -1660,14 +1660,19 @@ static int handle_statechange(void *datap)
|
||||
struct member *m;
|
||||
struct call_queue *q;
|
||||
char interface[80], *slash_pos;
|
||||
int found = 0;
|
||||
int found = 0; /* Found this member in any queue */
|
||||
int found_member; /* Found this member in this queue */
|
||||
int avail = 0; /* Found an available member in this queue */
|
||||
|
||||
qiter = ao2_iterator_init(queues, 0);
|
||||
while ((q = ao2_t_iterator_next(&qiter, "Iterate over queues"))) {
|
||||
ao2_lock(q);
|
||||
|
||||
avail = 0;
|
||||
found_member = 0;
|
||||
miter = ao2_iterator_init(q->members, 0);
|
||||
for (; (m = ao2_iterator_next(&miter)); ao2_ref(m, -1)) {
|
||||
if (!found_member) {
|
||||
ast_copy_string(interface, m->state_interface, sizeof(interface));
|
||||
|
||||
if ((slash_pos = strchr(interface, '/'))) {
|
||||
@@ -1677,12 +1682,31 @@ static int handle_statechange(void *datap)
|
||||
}
|
||||
|
||||
if (!strcasecmp(interface, sc->dev)) {
|
||||
found = 1;
|
||||
found_member = 1;
|
||||
update_status(q, m, sc->state);
|
||||
}
|
||||
}
|
||||
|
||||
/* check every member until we find one NOT_INUSE */
|
||||
if (!avail && (m->status == AST_DEVICE_NOT_INUSE) && !m->paused) {
|
||||
avail = 1;
|
||||
}
|
||||
if (avail && found_member) {
|
||||
/* early exit as we've found an available member and the member of interest */
|
||||
ao2_ref(m, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_member) {
|
||||
found = 1;
|
||||
if (avail) {
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Queue:%s_avail", q->name);
|
||||
} else {
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, "Queue:%s_avail", q->name);
|
||||
}
|
||||
}
|
||||
|
||||
ao2_iterator_destroy(&miter);
|
||||
|
||||
ao2_unlock(q);
|
||||
@@ -5853,6 +5877,10 @@ static int remove_from_queue(const char *queuename, const char *interface)
|
||||
dump_queue_members(q);
|
||||
}
|
||||
|
||||
if (!ao2_container_count(q->members)) {
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, "Queue:%s_avail", q->name);
|
||||
}
|
||||
|
||||
res = RES_OKAY;
|
||||
} else {
|
||||
res = RES_EXISTS;
|
||||
@@ -5933,6 +5961,10 @@ static int add_to_queue(const char *queuename, const char *interface, const char
|
||||
dump_queue_members(q);
|
||||
}
|
||||
|
||||
if (ao2_container_count(q->members) == 1) {
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Queue:%s_avail", q->name);
|
||||
}
|
||||
|
||||
res = RES_OKAY;
|
||||
} else {
|
||||
res = RES_OUTOFMEMORY;
|
||||
|
@@ -708,6 +708,12 @@ include => demo
|
||||
;exten => 6600,hint,park:701@parkedcalls
|
||||
;exten => 6600,1,noop
|
||||
;
|
||||
|
||||
;To subscribe to the availability of a free member in the 'markq' queue.
|
||||
;Note: '_avail' is added to the QueueName
|
||||
;exten => 8501,hint,Queue:markq_avail
|
||||
;exten => 8501,1,Queue(markq)
|
||||
|
||||
; Some other handy things are an extension for checking voicemail via
|
||||
; voicemailmain
|
||||
;
|
||||
|
Reference in New Issue
Block a user