Browse Source

dispatcher: helpers for routing

3.20
lazedo 11 years ago
parent
commit
46c5d0720b
1 changed files with 36 additions and 9 deletions
  1. +36
    -9
      kamailio/dispatcher-role.cfg

+ 36
- 9
kamailio/dispatcher-role.cfg View File

@ -71,8 +71,20 @@ route[DISPATCHER_FIND_ROUTES]
if (is_method("INVITE")) { if (is_method("INVITE")) {
$var(replaced_call_id) = "none";
if( $(ou{uri.param,kazoo-id}{s.len}) > 0) {
if($hdr(Replaces)== $null) {
$var(replaced_call_id) = $(ou{uri.param,kazoo-id}{s.unescape.param});
append_hf("Replaces: $var(replaced_call_id)\r\n");
}
}
if($hdr(Replaces)!= $null) { if($hdr(Replaces)!= $null) {
$var(replaced_call_id) = $(hdr(Replaces){s.select,0,;}); $var(replaced_call_id) = $(hdr(Replaces){s.select,0,;});
}
if($var(replaced_call_id) != "none") {
xlog("L_INFO", "$ci|log|replaces call-id $var(replaced_call_id)"); xlog("L_INFO", "$ci|log|replaces call-id $var(replaced_call_id)");
$var(amqp_payload_request) = '{"Event-Category" : "call_event" , "Event-Name" : "channel_status_req", "Call-ID" : "' + $var(replaced_call_id) + '", "Active-Only" : true }'; $var(amqp_payload_request) = '{"Event-Category" : "call_event" , "Event-Name" : "channel_status_req", "Call-ID" : "' + $var(replaced_call_id) + '", "Active-Only" : true }';
$var(amqp_routing_key) = "call.status_req." + $(var(replaced_call_id){kz.encode}); $var(amqp_routing_key) = "call.status_req." + $(var(replaced_call_id){kz.encode});
@ -83,15 +95,30 @@ route[DISPATCHER_FIND_ROUTES]
return; return;
} }
} }
}
##### CALL-PARK ####
if($(ru{uri.user}) =~ "\*3" && $sht(park=>$(ru{uri.user})@$(ru{uri.domain})) != $null) {
$du = $sht(park=>$(ru{uri.user})@$(ruri{uri.domain}));
$sht(park=>$(ru{uri.user})@$(ruri{uri.domain})) = $null;
xlog("L_INFO", "$ci|log|redirecting park request to $du");
return;
}
}
##### CALL-PARK ####
if($(ru{uri.user}) =~ "\*3" && $sht(park=>$(ru{uri.user})@$(ru{uri.domain})) != $null) {
$du = $sht(park=>$(ru{uri.user})@$(ruri{uri.domain}));
$sht(park=>$(ru{uri.user})@$(ruri{uri.domain})) = $null;
xlog("L_INFO", "$ci|log|redirecting park request to $du");
return;
}
##### CALL-PARK IN KAZOO ####
if($(ru{uri.user}) =~ "\*3" && !($rd =~ "[0-9]{1,3}\.[0-9]{1,3}.[0-9]{1,3}\.[0-9]{1,3}") ) {
xlog("L_INFO", "$ci|log|checking park request to $(ru{uri.user})@$(ru{uri.domain})");
$var(amqp_payload_request) = '{"Event-Category" : "call_event" , "Event-Name" : "query_user_channels_req", "Username" : "$(ru{uri.user})", "Realm" : "$(ru{uri.domain})", "Active-Only" : true }';
$var(amqp_routing_key) = "call.status_req." + $(var(replaced_call_id){kz.encode});
if(kazoo_query("callevt", $var(amqp_routing_key), $var(amqp_payload_request))) {
$du = $(kzR{kz.json,Channels[0].switch_url});
if($du != $null) {
xlog("L_INFO", "$ci|log|redirecting park request to $du, courtesy of kazoo");
return;
}
}
}
} }


Loading…
Cancel
Save