Completing opensips_async tutorial, remove debug info in sessionmanager

This commit is contained in:
DanB
2015-05-11 08:59:34 +02:00
parent 2b362b3a4d
commit dcc474646f
3 changed files with 53 additions and 42 deletions

View File

@@ -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()) {

View File

@@ -293,7 +293,7 @@ func TestTutOsipsCallsCdrs(t *testing.T) {
} else if len(reply) != 1 {
t.Error("Unexpected number of CDRs returned: ", len(reply))
} else {
if reply[0].CdrSource != "KAMAILIO_CGR_CALL_END" {
if reply[0].CdrSource != "OSIPS_E_ACC_EVENT" {
t.Errorf("Unexpected CdrSource for CDR: %+v", reply[0])
}
if reply[0].ReqType != utils.META_PREPAID {
@@ -322,7 +322,7 @@ func TestTutOsipsCallsCdrs(t *testing.T) {
} else if len(reply) != 1 {
t.Error("Unexpected number of CDRs returned: ", len(reply))
} else {
if reply[0].CdrSource != "KAMAILIO_CGR_CALL_END" {
if reply[0].CdrSource != "OSIPS_E_ACC_EVENT" {
t.Errorf("Unexpected CdrSource for CDR: %+v", reply[0])
}
if reply[0].ReqType != utils.META_POSTPAID {
@@ -341,7 +341,7 @@ func TestTutOsipsCallsCdrs(t *testing.T) {
} else if len(reply) != 1 {
t.Error("Unexpected number of CDRs returned: ", len(reply))
} else {
if reply[0].CdrSource != "KAMAILIO_CGR_CALL_END" {
if reply[0].CdrSource != "OSIPS_E_ACC_EVENT" {
t.Errorf("Unexpected CdrSource for CDR: %+v", reply[0])
}
if reply[0].ReqType != utils.META_PSEUDOPREPAID {
@@ -360,7 +360,7 @@ func TestTutOsipsCallsCdrs(t *testing.T) {
} else if len(reply) != 1 {
t.Error("Unexpected number of CDRs returned: ", len(reply))
} else {
if reply[0].CdrSource != "KAMAILIO_CGR_CALL_END" {
if reply[0].CdrSource != "OSIPS_E_ACC_EVENT" {
t.Errorf("Unexpected CdrSource for CDR: %+v", reply[0])
}
if reply[0].ReqType != utils.META_RATED {
@@ -379,7 +379,7 @@ func TestTutOsipsCallsCdrs(t *testing.T) {
} else if len(reply) != 1 {
t.Error("Unexpected number of CDRs returned: ", len(reply))
} else {
if reply[0].CdrSource != "KAMAILIO_CGR_CALL_END" {
if reply[0].CdrSource != "OSIPS_E_ACC_EVENT" {
t.Errorf("Unexpected CdrSource for CDR: %+v", reply[0])
}
if reply[0].ReqType != utils.META_PREPAID {
@@ -398,7 +398,7 @@ func TestTutOsipsCallsCdrs(t *testing.T) {
} else if len(reply) != 1 {
t.Error("Unexpected number of CDRs returned: ", len(reply))
} else {
if reply[0].CdrSource != "KAMAILIO_CGR_CALL_END" {
if reply[0].CdrSource != "OSIPS_E_ACC_EVENT" {
t.Errorf("Unexpected CdrSource for CDR: %+v", reply[0])
}
if reply[0].ReqType != utils.META_PREPAID {

View File

@@ -188,7 +188,6 @@ func (osipsEv *OsipsEvent) GetOriginatorIP(fieldName string) string {
return osipsEv.osipsEvent.OriginatorAddress.IP.String()
}
func (osipsev *OsipsEvent) MissingParameter() bool {
engine.Logger.Debug(fmt.Sprintf("Missing parameters on: %+v", osipsev.osipsEvent))
var nilTime time.Time
if osipsev.GetName() == "E_ACC_EVENT" && osipsev.osipsEvent.AttrValues["method"] == "INVITE" {
return len(osipsev.GetUUID()) == 0 ||