Hi,

$cnt is useful -- didn't know about it!

But I wonder, can you not just combine these operations into one loop?

   while($xavp(tm_contacts[$var(k)]) ne $null)

or 

   while(defined $xavp(tm_contacts[$var(k)]))

-- Alex

> On Dec 10, 2024, at 8:32 am, Fred Posner via sr-users 
> <[email protected]> wrote:
> 
> Hi,
> 
> You can use $cnt(pv) to count the number of xvps…
> 
> https://www.kamailio.org/wikidocs/cookbooks/5.8.x/pseudovariables/#cntpv-count-number-of-pvs
> 
> And then do a while ($xavp(tm_contacts[$var(k)]) < the count.
> 
> 
> Regards,
> 
> Fred Posner
> 
> 
> 
> 
>> On Dec 10, 2024, at 5:47 AM, Benoit Panizzon via sr-users 
>> <[email protected]> wrote:
>> 
>> Hi List
>> 
>> I'm trying to inspect the content of the $xavp(tm_contacts) to figure
>> out how t_load_contacts exactly behaves when called multiple times.
>> 
>>               $var(k) = 0;
>>               while ($xavp(tm_contacts[$var(k)]) != $null) {
>>                       $var(out) = "nothing";
>>                       xavp_params_implode("tm_contacts[$var(k)]", 
>> "$var(out)");
>>                       xlog("L_INFO", "$cfg(route): tm_contacts idx: $var(k) 
>> => $var(out)\n");
>>                       $var(k) = $var(k) + 1;
>>               }
>> 
>> My stack contains multiple entries.
>> 
>> Unfortunately I struggle to access the lower entries.
>> 
>> xavp_params_implode("tm_contacts[$var(k)]", "$var(out)");
>> 
>> does nothing when $var(k) > 0
>> 
>> What is the best way to dump a complete xavp stack?
>> 
>> I suspect t_load_contacts does flush the complete stack. Is there a way
>> to stack an xavp on top of another one?
>> 
>> Something like:
>> 
>> xavp_rm("contact_stack"); # Initialize Stack
>> 
>> lookup("location", "sip:[email protected]");
>> t_load_contacts(0);
>> 
>> $xavp(contact_stack) = $xavp(tm_contacts); 
>> 
>> lookup("location", "sip:[email protected]");
>> t_load_contacts(0);
>> 
>> $xavp(contact_stack) = $xavp(tm_contacts); # contact_stack now contains 
>> alice + bob
>> 
>> lookup("location", "sip:[email protected]");
>> t_load_contacts(0);
>> 
>> # $xavp(tm_contacts) now contains only charlie.
>> 
>> $xavp(tm_contacts) = $xavp(contact_stack);
>> 
>> # $xavp(tm_contacts) now contains only alice, bob + charlie.
>> 
>> t_next_contacts(); # Push contacts to destination list creating branches.
>> t_relay(); # Invite all contacts
>> 
>> Mit freundlichen Grüssen
>> 
>> -Benoît Panizzon-
>> -- 
>> I m p r o W a r e   A G    -    Leiter Commerce Kunden
>> ______________________________________________________
>> 
>> Zurlindenstrasse 29             Tel  +41 61 826 93 00
>> CH-4133 Pratteln                Fax  +41 61 826 93 01
>> Schweiz                         Web  http://www.imp.ch
>> ______________________________________________________
>> __________________________________________________________
>> Kamailio - Users Mailing List - Non Commercial Discussions -- 
>> [email protected]
>> To unsubscribe send an email to [email protected]
>> Important: keep the mailing list in the recipients, do not reply only to the 
>> sender!
> 
> __________________________________________________________
> Kamailio - Users Mailing List - Non Commercial Discussions -- 
> [email protected]
> To unsubscribe send an email to [email protected]
> Important: keep the mailing list in the recipients, do not reply only to the 
> sender!

-- 
Alex Balashov
Principal Consultant
Evariste Systems LLC
Web: https://evaristesys.com
Tel: +1-706-510-6800

__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions -- 
[email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to