Skip to content

Commit

Permalink
Add queue_pos_param module param to report the queue position.
Browse files Browse the repository at this point in the history
The name of an SIP URI parameter to be used to report the position in the waiting queue when sending the call to media server for onwait/queue playback. The position 0 means it is the next call to be delivered to an agent.
  • Loading branch information
bogdan-iancu committed Feb 5, 2017
1 parent 1e21f91 commit 1e1307f
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 34 deletions.
58 changes: 37 additions & 21 deletions modules/call_center/README
Expand Up @@ -31,6 +31,7 @@ Bogdan-Andrei Iancu
1.4.2. acc_db_url (string)
1.4.3. b2b_scenario (string)
1.4.4. wrapup_time (integer)
1.4.5. queue_pos_param (string)

1.5. Exported Functions

Expand Down Expand Up @@ -67,8 +68,9 @@ Bogdan-Andrei Iancu
1.2. Set acc_db_url parameter
1.3. Set b2b_scenario parameter
1.4. Set wrapup_time parameter
1.5. cc_handle_call usage
1.6. cc_agent_login usage
1.5. Set queue_pos_param parameter
1.6. cc_handle_call usage
1.7. cc_agent_login usage

Chapter 1. Admin Guide

Expand Down Expand Up @@ -238,6 +240,20 @@ modparam("call_center", "b2b_scenario", "call center")
modparam("call_center", "wrapup_time", 45)
...

1.4.5. queue_pos_param (string)

The name of an SIP URI parameter to be used to report the
position in the waiting queue when sending the call to media
server for onwait/queue playback. The position 0 means it is
the next call to be delivered to an agent.

Default value is “empty(none)”.

Example 1.5. Set queue_pos_param parameter
...
modparam("call_center", "queue_pos_param", "cc_pos")
...

1.5. Exported Functions

1.5.1. cc_handle_call(flowID)
Expand Down Expand Up @@ -265,7 +281,7 @@ modparam("call_center", "wrapup_time", 45)
* -4 - no agents logged in the flow;
* -5 - internal error;

Example 1.5. cc_handle_call usage
Example 1.6. cc_handle_call usage
...
if (is_method("INVITE") and !has_totag()) {
if (!cc_handle_call("tech_support")) {
Expand All @@ -285,7 +301,7 @@ if (is_method("INVITE") and !has_totag()) {
state is an integer value giving the new state - 0 means logged
off, anything else means logged in.

Example 1.6. cc_agent_login usage
Example 1.7. cc_agent_login usage
...
# log off the 'agentX' agent
cc_agent_login("agentX","0");
Expand Down Expand Up @@ -484,31 +500,31 @@ Chapter 3. Frequently Asked Questions

3.1.

Where can I find more about OpenSIPS?
Where can I find more about OpenSIPS?

Take a look at http://www.opensips.org/.
Take a look at http://www.opensips.org/.

3.2.

Where can I post a question about this module?
Where can I post a question about this module?

First at all check if your question was already answered on one
of our mailing lists:
* User Mailing List -
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
* Developer Mailing List -
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
First at all check if your question was already answered on one
of our mailing lists:
* User Mailing List -
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
* Developer Mailing List -
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel

E-mails regarding any stable OpenSIPS release should be sent to
<users@lists.opensips.org> and e-mails regarding development
versions should be sent to <devel@lists.opensips.org>.
E-mails regarding any stable OpenSIPS release should be sent to
<users@lists.opensips.org> and e-mails regarding development
versions should be sent to <devel@lists.opensips.org>.

If you want to keep the mail private, send it to
<users@lists.opensips.org>.
If you want to keep the mail private, send it to
<users@lists.opensips.org>.

3.3.

How can I report a bug?
How can I report a bug?

Please follow the guidelines provided at:
https://github.com/OpenSIPS/opensips/issues.
Please follow the guidelines provided at:
https://github.com/OpenSIPS/opensips/issues.
24 changes: 15 additions & 9 deletions modules/call_center/call_center.c
Expand Up @@ -85,6 +85,9 @@ stat_var *stg_onhold_calls = 0;
/* a default of 30 secs wrapup time for agents */
unsigned int wrapup_time = 30;

/* the name of the URI param to report the queue position */
str queue_pos_param = {NULL,0};



static cmd_export_t cmds[]={
Expand All @@ -101,12 +104,13 @@ static param_export_t mod_params[]={
{ "acc_db_url", STR_PARAM, &acc_db_url.s },
{ "b2b_scenario", STR_PARAM, &b2b_scenario.s },
{ "wrapup_time", INT_PARAM, &wrapup_time },
{ "queue_pos_param", STR_PARAM, &queue_pos_param.s },
{ 0,0,0 }
};


static mi_export_t mi_cmds[] = {
{ "cc_reload", "", mi_cc_reload, MI_NO_INPUT_FLAG, 0, mi_child_init},
{ "cc_reload", "", mi_cc_reload, MI_NO_INPUT_FLAG,0,mi_child_init},
{ "cc_agent_login", "", mi_agent_login, 0, 0, 0},
{ "cc_list_queue", "", mi_cc_list_queue, MI_NO_INPUT_FLAG, 0, 0},
{ "cc_list_flows", "", mi_cc_list_flows, MI_NO_INPUT_FLAG, 0, 0},
Expand All @@ -118,14 +122,14 @@ static mi_export_t mi_cmds[] = {


static stat_export_t mod_stats[] = {
{"ccg_incalls", 0, &stg_incalls },
{"ccg_awt", STAT_IS_FUNC, (stat_var**)stg_awt },
{"ccg_load", STAT_IS_FUNC, (stat_var**)stg_load },
{"ccg_distributed_incalls", 0, &stg_dist_incalls },
{"ccg_answered_incalls" , 0, &stg_answ_incalls },
{"ccg_abandonned_incalls" , 0, &stg_aban_incalls },
{"ccg_onhold_calls", STAT_NO_RESET, &stg_onhold_calls },
{"ccg_free_agents", STAT_IS_FUNC, (stat_var**)stg_free_agents },
{"ccg_incalls", 0, &stg_incalls },
{"ccg_awt", STAT_IS_FUNC, (stat_var**)stg_awt },
{"ccg_load", STAT_IS_FUNC, (stat_var**)stg_load },
{"ccg_distributed_incalls", 0, &stg_dist_incalls },
{"ccg_answered_incalls" , 0, &stg_answ_incalls },
{"ccg_abandonned_incalls" , 0, &stg_aban_incalls },
{"ccg_onhold_calls", STAT_NO_RESET, &stg_onhold_calls },
{"ccg_free_agents", STAT_IS_FUNC, (stat_var**)stg_free_agents },
{0,0,0}
};

Expand Down Expand Up @@ -240,6 +244,8 @@ static int mod_init(void)
init_db_url( db_url , 0 /*cannot be null*/);
init_db_url( acc_db_url , 0 /*cannot be null*/);
b2b_scenario.len = strlen(b2b_scenario.s);
if (queue_pos_param.s)
queue_pos_param.len = strlen(queue_pos_param.s);

/* Load B2BUA API */
if (load_b2b_logic_api( &b2b_api) != 0) {
Expand Down
4 changes: 3 additions & 1 deletion modules/call_center/cc_data.c
Expand Up @@ -915,7 +915,7 @@ void print_queue(struct cc_data *data)
}


void cc_queue_push_call(struct cc_data *data, struct cc_call *call, int top)
int cc_queue_push_call(struct cc_data *data, struct cc_call *call, int top)
{
struct cc_call *call_it;
int n = 0;
Expand Down Expand Up @@ -971,6 +971,8 @@ void cc_queue_push_call(struct cc_data *data, struct cc_call *call, int top)

if (call->queue_start==0)
call->queue_start = get_ticks();

return data->queue.calls_no-1-n;
}


Expand Down
2 changes: 1 addition & 1 deletion modules/call_center/cc_data.h
Expand Up @@ -227,7 +227,7 @@ void clean_cc_old_data(struct cc_data *data);

void clean_cc_unref_data(struct cc_data *data);

void cc_queue_push_call(struct cc_data *data, struct cc_call *call, int top);
int cc_queue_push_call(struct cc_data *data, struct cc_call *call, int top);

struct cc_call *cc_queue_pop_call_for_agent(struct cc_data *data,
struct cc_agent *agent);
Expand Down
23 changes: 21 additions & 2 deletions modules/call_center/cc_queue.c
Expand Up @@ -24,10 +24,12 @@
* 2014-03-17 initial version (bogdan)
*/

#include "../../ut.h"
#include "cc_queue.h"

extern stat_var *stg_terminated_calls;
extern stat_var *stg_dist_incalls;
extern str queue_pos_param;


/* this function must be call under
Expand All @@ -40,6 +42,9 @@ int cc_call_state_machine(struct cc_data *data, struct cc_call *call,
struct cc_agent *agent;
str *out = NULL;
int state =0;
int pos = -1;
int len;
char *s;

switch (call->state) {
case CC_CALL_NONE:
Expand Down Expand Up @@ -81,7 +86,7 @@ int cc_call_state_machine(struct cc_data *data, struct cc_call *call,
break;
}
/* add it to queue */
cc_queue_push_call( data, call, 0);
pos = cc_queue_push_call( data, call, 0);
}
break;
case CC_CALL_TOAGENT:
Expand All @@ -94,10 +99,24 @@ int cc_call_state_machine(struct cc_data *data, struct cc_call *call,
}

if (out) {
leg->s = (char*)pkg_malloc( out->len );
/* compute the new SIP URI */
/* report the queue position ? */
if (queue_pos_param.s && pos>=0)
s = int2str((unsigned long)pos, &len);
else
s = NULL;
leg->s = (char*)pkg_malloc(out->len+(s?(queue_pos_param.len+len+2):0));
if (leg->s) {
leg->len = out->len;
memcpy(leg->s,out->s,out->len);
if (s) {
leg->s[leg->len++] = ';';
memcpy(leg->s+leg->len, queue_pos_param.s,queue_pos_param.len);
leg->len += queue_pos_param.len;
leg->s[leg->len++] = '=';
memcpy(leg->s+leg->len, s, len);
leg->len += len;
}
call->prev_state = call->state;
call->state = state;
return 0;
Expand Down
22 changes: 22 additions & 0 deletions modules/call_center/doc/call_center_admin.xml
Expand Up @@ -250,8 +250,30 @@ modparam("call_center", "wrapup_time", 45)
</example>
</section>

<section>
<title><varname>queue_pos_param</varname> (string)</title>
<para>
The name of an SIP URI parameter to be used to report the position
in the waiting queue when sending the call to media server for
onwait/queue playback. The position 0 means it is the next call
to be delivered to an agent.
</para>
<para>
<emphasis>Default value is <quote>empty(none)</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>queue_pos_param</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("call_center", "queue_pos_param", "cc_pos")
...
</programlisting>
</example>
</section>

</section>


<section>
<title>Exported Functions</title>
Expand Down

0 comments on commit 1e1307f

Please sign in to comment.