Hi,
You can use $cnt(pv) to count the number of xvps…
https://www.kamailio.org/wikidocs/cookbooks/5.8.x/pseudovariables/#cntpv-cou...
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 sr-users@lists.kamailio.org 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:alice@example.com"); t_load_contacts(0);
$xavp(contact_stack) = $xavp(tm_contacts);
lookup("location", "sip:bob@example.com"); t_load_contacts(0);
$xavp(contact_stack) = $xavp(tm_contacts); # contact_stack now contains alice + bob
lookup("location", "sip:carlie@example.com"); 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 -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!