I'm trying to limit all subscriber's active call according to setting their simultaneous use setting defined in database.
But having problem when one subscriber's INVITE message goes to retransmission. When retranmission occures INVITE messages don't complete with BYE and subscriber simultaneus use amount will hung.
My example code block is below.
Thanks.
modparam("dialog", "db_url", "mysql://openser:openserrw@localhost/openser")
modparam("dialog", "dlg_flag", 4)
modparam("dialog", "db_mode", 1)
modparam("dialog","profiles_with_value","callquota")
modparam("dialog", "default_timeout", 3600)
modparam("dialog", "dlg_match_mode",0)
modparam("dialog", "detect_spirals", 1)
route[QUOTA] {
if (is_method("INVITE") && $fU == $avp(s:username)) {
avp_db_query("select quota from subscriber where username='$avp(s:username)'", "$avp(s:quota)");
$var(SIZE) = 0;
get_profile_size("callquota", "$avp(s:username)", "$var(SIZE)");
xlog("L_INFO", "CALL_OPENSER:Call originated from = $fd\n");
xlog("L_INFO", "Active call amount for $fU is $var(SIZE) , quota=$avp(s:quota)\n");
if( $var(SIZE) >= $avp(s:quota) ){
sl_send_reply("403", "Simultaneous calls limit reached");
xlog("L_INFO", "QUOTA:Limit of $var(SIZE) active calls has been reached for user=$avp(s:username), quota=$avp(s:quota)\n");
exit;
}
set_dlg_profile("callquota","$avp(s:username)");
get_profile_size("callquota", "$avp(s:username)", "$var(SIZE)");
}
}