Thank you, Bruno!

Regarding this test:
        if ($hdr(User-Agent)=~$(ulc(caller=>user_agent)[$var(i)]))
        {

Shouldn't the =~ be replaced with == so that user agent strings aren't misinterpretted as regular expressions? It appears to work on my end with == when I tested just now.

Also, for user agents that provide an instance ID, is there a way to access this from $hdr(...) ? I'd like to also compare against $(ulc(caller=>instance)[$var(i)]) in order to allow duplicate user agents as long as they have differing instance ID's. (To allow a user to run the same softwre on multiple devices...)

- David


On Fri, May 13, 2016 at 12:24:37PM -0300, Bruno Emer wrote:
Hello all!

After some time I was able to get this working here, and now I am coming
back to share my configuration with you guys (in case someone needs to get
this working).

Here is what we have done:

route[REGISTRAR] {
       if (is_method("REGISTER"))
       {
               if(isflagset(FLT_NATS))
               {
                       setbflag(FLB_NATB);
                       # uncomment next line to do SIP NAT pinging
                       ## setbflag(FLB_NATSIPPING);
               }

               xlog("L_INFO", "checking $tu registered with 
User-Agent:$hdr(User-Agent)\n");
               if(reg_fetch_contacts("location", "$tu", "caller"))
               {
                       xlog("L_INFO", "$(ulc(caller=>count)) records found for 
$tu\n");
                       $var(i) = 0;
                       while($var(i) < $(ulc(caller=>count)))
                       {

                               xlog("L_INFO", "record $var(i) with 
ruid:$(ulc(caller=>ruid)[$var(i)]) - User-Agent:$(ulc(caller=>user_agent)[$var(i)])");
                               if 
($hdr(User-Agent)=~$(ulc(caller=>user_agent)[$var(i)]))
                               {
                                       $var(ruid) = 
$(ulc(caller=>ruid)[$var(i)]);
                                       xlog("L_INFO", "unregistering $tu 
ruid:$var(ruid)");
                                       unregister("location", "$tu", 
"$var(ruid)");
                               }
                               $var(i) = $var(i) + 1;
                       }
               }
               if (!save("location", "0x00"))
                       sl_reply_error();

               exit;
       }
}


There are some logs over there because we used it to see what was going on
while testing the configurations.


With this we can get just one register per User-Agent.


And again, thanks Olle for your help in this problem

*Bruno Emer*

Mobile: +55 11 96540-0044
email: brunoe...@gmail.com
<https://www.facebook.com/bruno.emer.5>
<https://www.linkedin.com/profile/view?id=86461237&trk=spm_pic>
<https://twitter.com/brunoemer_>
<https://www.flickr.com/photos/122070309@N03/>
<http://google.com/+BrunoEmer>  <http://instagram.com/brunoemer_>

2016-04-01 17:37 GMT-03:00 Bruno Emer <brunoe...@gmail.com>:

Sure it is!

This is exactly what I was looking for! Actually I wasn't able to see that
there was a way to perform this action!

Thanks for your help, Olle!

I will try to create this, and when I have it done, I will post my script
here, so if someone else need the same problem I can help.

Now, I have just one more question about my scenario: when I register a
user, is there a way to create something like a "custom field" on the
location? To explain better: If possible, I can add something like a custom
header that says if the user is registered from a phone device or the web
interface, then I can perform the loop and replace only the oldest contact
using that device...



*Bruno Emer*

Mobile: +55 11 96540-0044
email: brunoe...@gmail.com

2016-04-01 17:18 GMT-03:00 Bruno Emer <brunoe...@gmail.com>:

This is my problem... I want to have 2 contacts for AOR, and not only
one.

When the 3rd arrives, it must remove the oldest and continue with 2...

*If I am using the 0x04 parameter, it will save just one contact, and the
user will not be able to get the Invite both, in the mobile device and web
interface.*

*Bruno Emer*

Mobile: +55 11 96540-0044
email: brunoe...@gmail.com
<https://www.facebook.com/bruno.emer.5>
<https://www.linkedin.com/profile/view?id=86461237&trk=spm_pic>
<https://twitter.com/brunoemer_>
<https://www.flickr.com/photos/122070309@N03/>
<http://google.com/+BrunoEmer>  <http://instagram.com/brunoemer_>

2016-04-01 17:07 GMT-03:00 Bruno Emer <brunoe...@gmail.com>:

Hello, *Olle!*

*Thanks for your help in this case, and don't worry about the time
(actually I wasn't even expecting to get an answer today).*


*I know the max_contacts parameter. But the problem is that if I set the
max_contacts to 2, when the user tries to register again, he gets an error
message 503. The point is that I want to get the user registered, and
replace the oldest location entry for the newest one.*



*Bruno Emer*

Mobile: +55 11 96540-0044
email: brunoe...@gmail.com

2016-04-01 16:31 GMT-03:00 Bruno Emer <brunoe...@gmail.com>:

Hello all.

I have problem here and I tried to find a solution and search over
internet, but without success.

My scenario is the following: I have an application that must be
registered in Kamailio when a user logs in the web interface, so he can get
calls (something like a web softphone using webrtc). At this point, we are
OK, and everything is working fine.

To get these register functions I am using the parameter
"save("location", "0x04")" as described in the REGISTRAR module
documentation, so if a user logs in another web browser or computer, only
the last one will continue registered and all calls will be forwarded to
him.

The point is that now we are creating a phone app that will do almost
the same thing as the web interface, allowing users to receive calls using
the mobile device, and here is my problem: I want to allow my users to be
registered on two devices at the same time, but if a user logs into another
device, I don't want to reply with a 503. I want to allow the user to
register again, deregistering the oldest contact.

I saw that there is a module named "ims_usrloc_scscf" and on its
description it says "implemented overwrite oldest contact behaviour",
but I couldn't find any documentation about it.

So, is there a way to get this working today?


*Bruno Emer*

Mobile: +55 11 96540-0044
email: brunoe...@gmail.com




Attachment: signature.asc
Description: PGP signature

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to