Hello,

I am using exact same logic for which is define in this documentation and 
single device its working fine.
https://www.kamailio.org/events/2015-KamailioWorld/Day2/20-Federico.Cabiddu-Kamailio-In-A-Mobile-World.pdf

But seems like if multiple registration with same extension, like if extension 
102 logged in mobile as well web. If web device registered and mobile is not 
registered with wss, then the Current transaction is not going to suspend due 
to its consider like there is only one location entry on location table.so only 
one Invite send to web and mobile its going to send notification but never get 
Invite, even it is going to register using push notification.

So below LOCATION function should be called and sending invite to registered 
extension and should be waiting for Other device as well. But in my case its 
consider like only one device is there and transaction is not suspending.

Could you check and suggest me which part of code need to improve to so i can 
make it working with registered device with parallel forking for adding new 
branch.

Here is my code.

modparam("registrar", "max_contacts", 10)
modparam("registrar", "append_branches", 1)
modparam("registrar", "use_path", 1)
modparam("registrar", "path_mode", 1)

loadmodule "tsilo.so"
modparam("tsilo", "use_domain", 1)

modparam("htable", "htable", "vtp=>size=100;autoexpire=30;")

# append branches or resume the transaction
route[PUSHJOIN] {
    $var(hjoin) = 0;
    lock("$tU");
    $var(hjoin) = $sht(vtp=>join::$tU);
    $var(hstored) = $sht(vtp=>stored::$tU);
    $sht(vtp=>join::$tU) = $null;
    unlock("$tU");
    if ($var(hjoin)==0)
    {
        if ($var(hstored))
            ts_append("location", "$tU");
        return;
    }
    $var(id_index) = $(var(hjoin){s.select,0,:}{s.int});
    $var(id_label) = $(var(hjoin){s.select,1,:}{s.int});
    t_continue("$var(id_index)", "$var(id_label)", "INVRESUME");
}

# lookup and relay after resuming transaction
route[INVRESUME] {
    lookup("location");
    xlog("L_INFO","[RESUME] rm=$rm ru=$ru du=$du \n");
    t_relay();
    ts_store();
    $sht(vtp=>stored::$rU) = 1;
    $sht(vtp=>id_index::$tu) = $null;
    $sht(vtp=>id_label::$tu) = $null;
    xlog("L_INFO","stored transaction [$T(id_index):$T(id_label)] $fU => 
$rU\n");
}

route[SUSPEND] {
    if ( !t_suspend() ) {
       xlog("L_ERROR","[SUSPEND]  failed suspending trasaction 
[$T(id_index):$T(id_label)]\n");
       send_reply("501", "Suspending error");
       exit;
    } 
    xlog("L_INFO","[SUSPEND]  suspended transaction [$T(id_index):$T(id_label)] 
$fU=> $rU\n");
    $sht(vtp=>join::$rU) = "" + $T(id_index) + ":" + $T(id_label);
    xlog("L_INFO","htable key value [$sht(vtp=>join::$rU)]\n");
}

route[SENDPUSH] {
       $avp(platform) = $hdr(X-pn-platform);
       $var(headers) = "Content-Type: application/json\r\nAuthorization: Bearer 
55466cc-c789-4a48-39c8-219ebaa1512f";
       $var(body) = "{\"user\": \"" + $rU + "\", " +
                                "\"platform\": \"" + $avp(platform) + "\"}";
        
http_client_query("https://handlepush.xxx.com/v2/phone/call/send_notification_kamalio";,
                        "$var(body)", 
                        "$var(headers)",
                        "$var(res)");

}

# User location service
route[LOCATION] {
       
        if (!lookup("location"))
        {
            send_reply("100", "Trying");
            xlog("L_INFO","SUSPENDING TRANASACTION $fU => $rU\n");
            route(SUSPEND);
        }
        else
        {
            t_relay();
            ts_store();
            $sht(vtp=>stored::$rU) = 1;
            xlog("L_INFO","stored transaction [$T(id_index):$T(id_label)] $fU=> 
$rU\n");
        }
        route(SENDPUSH);
        exit;
}


        if (is_method("REGISTER") || from_uri==myself) {
                  xlog("L_INFO", "SAVING TO LOCATIONS $si:$sp\n");
                  if (!save("location")) {
                        sl_reply_error();
                  }
                  route(PUSHJOIN);
                exit;
        }

Can you help me to understand why parallel forking not working in this case ?

Thanks
_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to