1.6.1. Push Notification
We use notify_on_event to capture the events on new contact registrations for callee. Once the call is sent to callee, based on the notification (for new contacts) we inject the newly registered contacts as new branches in the ongoing transaction.
Schematics : when we send a call to a user, we subscribe to see any new contacts being registered by the user. On such a notification, we add the new contact as a new branch to the ongoing transaction (ringing) to user.
Example 1.3. Push Notification script
...
route[route_to_user] {
# prepare transaction for branch injection; it is mandatory
# to create the transaction before the subscription, otherwise
# the EBR module will not pass the transaction ID into the
# notification route
t_newtran();
# keep the transaction alive (even if all branches will
# terminate) until the FR INVITE timer hits (we want to wait
# for new possible contacts being registered)
t_wait_for_new_branches();
# subscribe to new contact registration event,
# but for our callee only
$avp(filter) = "aor="+$rU;
notify_on_event("E_UL_CONTACT_INSERT",$avp(filter),
"fork_call", 20);
# fetch already registered contacts and relay if any
if (lookup("location"))
route(relay);
# if there were no contacts available (so no branches
# created so far), the created transaction will still be
# waiting for new branches due to the usage of the
# t_wait_for_new_branches() function
exit;
}
route[fork_call]
{
xlog("user $avp(aor) registered a new "
"contact $avp(uri), injecting\n");
# take the contact described by the E_UL_CONTACT_INSERT
# event and inject it as a new branch into the original
# transaction
t_inject_branches("event");
}
...