mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 21:29:52 +05:00
Completing opensips_async tutorial, remove debug info in sessionmanager
This commit is contained in:
@@ -128,8 +128,39 @@ local_route {
|
||||
}
|
||||
}
|
||||
|
||||
# main request routing logic
|
||||
## Send AUTH request to CGRateS engine
|
||||
route[CGR_AUTH_REQ] {
|
||||
# Code to produce the json
|
||||
$json(cgr_auth) := "{}";
|
||||
$json(cgr_auth/id) = "1";
|
||||
$json(cgr_auth/method) = "ApierV1.GetMaxSessionTime";
|
||||
$json(cgr_auth/params) := "[{}]";
|
||||
$json(cgr_auth/params[0]/ReqType) = $avp(cgr_reqtype);
|
||||
$json(cgr_auth/params[0]/Account) = $avp(cgr_account);
|
||||
$json(cgr_auth/params[0]/Destination) = $avp(cgr_destination);
|
||||
$json(cgr_auth/params[0]/DialogId) = $DLG_did;
|
||||
async(rest_post("http://127.0.0.1:2080/jsonrpc", "$json(cgr_auth)", "application/json", "$avp(cgr_auth_reply)", "$var(ct)", "$var(rcode)"), CGR_AUTH_REPLY);
|
||||
}
|
||||
|
||||
## Process answer received from CGRateS engine
|
||||
route[CGR_AUTH_REPLY] {
|
||||
$json(cgr_auth_reply) := $avp(cgr_auth_reply);
|
||||
xlog("In CGR_AUTH_REPLY, reply received: $json(cgr_auth_reply)");
|
||||
if $json(cgr_auth_reply/error) != NULL {
|
||||
xlog("Error received from CGRateS: $json(cgr_auth_reply/error)");
|
||||
sl_send_reply("503","Charging controller error");
|
||||
exit;
|
||||
} else if $json(cgr_auth_reply/result) == 0 {
|
||||
sl_send_reply("403","Payment required");
|
||||
exit;
|
||||
} else if $json(cgr_auth_reply/result) > -1 {
|
||||
$DLG_timeout=$json(cgr_auth_reply/result);
|
||||
}
|
||||
route(location);
|
||||
route(relay);
|
||||
}
|
||||
|
||||
# main request routing logic
|
||||
route{
|
||||
|
||||
|
||||
@@ -222,7 +253,21 @@ route{
|
||||
send_reply("500","Internal Server Error");
|
||||
exit;
|
||||
}
|
||||
$avp(cgr_reqtype)="*prepaid";
|
||||
switch ($fU) {
|
||||
case "1001":
|
||||
case "1006":
|
||||
case "1007":
|
||||
$avp(cgr_reqtype) = "*prepaid";
|
||||
break;
|
||||
case "1002":
|
||||
$avp(cgr_reqtype) = "*postpaid";
|
||||
break;
|
||||
case "1003":
|
||||
$avp(cgr_reqtype) = "*pseudoprepaid";
|
||||
break;
|
||||
default:
|
||||
$avp(cgr_reqtype) = "*rated";
|
||||
}
|
||||
$avp(cgr_account)=$fU;
|
||||
$avp(cgr_destination)=$rU;
|
||||
$avp(cgr_supplier)="supplier1";
|
||||
@@ -262,39 +307,6 @@ route{
|
||||
route(relay);
|
||||
}
|
||||
|
||||
## Send AUTH request to CGRateS engine
|
||||
route[CGR_AUTH_REQ] {
|
||||
# Code to produce the json
|
||||
$json(cgr_auth) := "{}";
|
||||
$json(cgr_auth/id) = "1";
|
||||
$json(cgr_auth/method) = "ApierV1.GetMaxSessionTime";
|
||||
$json(cgr_auth/params) := "[{}]";
|
||||
$json(cgr_auth/params[0]/ReqType) = $avp(cgr_reqtype);
|
||||
$json(cgr_auth/params[0]/Account) = $avp(cgr_account);
|
||||
$json(cgr_auth/params[0]/Destination) = $avp(cgr_destination);
|
||||
$json(cgr_auth/params[0]/DialogId) = $DLG_did;
|
||||
async(rest_post("http://127.0.0.1:2080/jsonrpc", "$json(cgr_auth)", "application/json", "$avp(cgr_auth_reply)", "$var(ct)", "$var(rcode)"), CGR_AUTH_REPLY);
|
||||
}
|
||||
|
||||
## Process answer received from CGRateS engine
|
||||
route[CGR_AUTH_REPLY] {
|
||||
$json(cgr_auth_reply) := $avp(cgr_auth_reply);
|
||||
xlog("In CGR_AUTH_REPLY, reply received: $json(cgr_auth_reply)");
|
||||
if $json(cgr_auth_reply/error) != NULL {
|
||||
xlog("Error received from CGRateS: $json(cgr_auth_reply/error)");
|
||||
sl_send_reply("503","Charging controller error");
|
||||
exit;
|
||||
} else if $json(cgr_auth_reply/result) == 0 {
|
||||
sl_send_reply("403","Payment required");
|
||||
exit;
|
||||
} else if $json(cgr_auth_reply/result) > -1 {
|
||||
$DLG_timeout=$json(cgr_auth_reply/result);
|
||||
}
|
||||
route(location);
|
||||
route(relay);
|
||||
}
|
||||
|
||||
|
||||
route[relay] {
|
||||
# for INVITEs enable some additional helper routes
|
||||
if (is_method("INVITE") && !has_totag()) {
|
||||
|
||||
Reference in New Issue
Block a user