Login | Register

Documentation

Documentation -> Tutorials -> Concurrent calls limitation 1.5

This page has been visited 3084 times.

Using the new 'dialog' module released with the 1.5x branch, it is now possible to easily impose channel limits within existing routing configurations. The example included below is a sample route block that integrates outbound channel limits with call control prepaid account support. Note that the example requires an AVP variable 'channels' to be set as user preference and can be adapted for both outbound and inbound channel limits using the existing profile architecture of the dialog module.

....
# define the profile
modparam("dialog", "profiles_with_value", "caller")
....

# Example route block:
#   this example should be called before the t_relay() function of an outbound invite
#
########################################################################
# Request route 'callcontrol' with channel limit
########################################################################

route[39]
{
	## have we done our checking on this call?
	if(!isflagset(31))
	{
		# user has max channel limit set as preference
		if(is_avp_set("$avp(s:channels)/n") && avp_check("$avp(s:channels)", "gt/i:0"))
		{
			# get current calls for uuid
			get_profile_size("caller","$avp(s:caller_uuid)","$var(calls)");	

			# check within limit
			if($avp(s:channels) > $var(calls))
			{
				xlog("L_INFO", "Call control: user '$avp(s:caller_uuid)' currently has 
				   '$var(calls)' of '$avp(s:channels)' active calls before this one\n");
				$var(setprofile) = 1;
			}
			else
			{
				xlog("L_INFO", "Call control: user channel limit exceeded [$var(calls)/$avp(s:channels)]\n");
				send_reply("487", "Request Terminated: Channel limit exceeded\n");
				exit;
			}
		}
		else
		{
			$var(setprofile) = 0;
		}

		call_control();

       	 	switch ($retcode) 
		{
        		case 2:
            			# Call with no limit
        		case 1:
            			# Call with a limit under callcontrol management (either prepaid or postpaid)
            			break;
        		case -1:
            			# Not enough credit (prepaid call)
            			xlog("L_INFO", "Call control: not enough credit for prepaid call\n");
            			acc_rad_request("402");
            			sl_send_reply("402", "Not enough credit");
            			exit;
            			break;
        		case -2:
           			# Locked by call in progress (prepaid call)
             			xlog("L_INFO", "Call control: prepaid call locked by another call in progress\n");
             			acc_rad_request("403");
             			sl_send_reply("403", "Call locked by another call in progress");
             			exit;
             			break;
        		default:
            			# Internal error (message parsing, communication, ...)
            			xlog("L_INFO", "Call control: internal server error\n");
            			acc_rad_request("500");
            			sl_send_reply("500", "Internal server error");
            			exit;
        	}

		if($var(setprofile) > 0)
		{
			create_dialog();
			set_dlg_profile("caller","$avp(s:caller_uuid)");
		}

		## mark checking done
		setflag(31);
	}
}

Add Comment 
Sign as Author 
Enter code 909


Page last modified on August 17, 2015, at 07:14 PM