<div dir="ltr"><div>Hi Bogdan,</div><div>yes. It works.</div><div>I am using it like this:</div><div><i><br></i></div><i>            $var(idx) = 0;<br>            $var(aor) = $(var(aors){s.select,$var(idx),,});<br>            <br>            while($var(aor) != null) {<br>                if($var(idx) > 0) {<br>                    append_branch();<br>                }<br><br>                seturi("sip:$var(aor)@$fd");<br><br>                $var(idx) = $var(idx) + 1;<br>                $var(aor) = $(var(aors){s.select,$var(idx),!});<br>            }<br><br>            if (lookup("location", "r")) {<br>                t_on_branch("USERAGENT_BRANCH");<br>                route(RELAY_REQUEST);<br>            } else {<br>                sl_send_reply(480, "subscriber not online retcode=$retcode");<br>            }<br></i><div>    <br></div><div>Thanks and regards,</div><div>Takeshi</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 11, 2022 at 6:32 PM Bogdan-Andrei Iancu <<a href="mailto:bogdan@opensips.org">bogdan@opensips.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <font face="monospace">Hi, and it works now, right?<br>
      <br>
      Regards,<br>
    </font>
    <pre cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a href="https://www.opensips-solutions.com" target="_blank">https://www.opensips-solutions.com</a>
OpenSIPS Summit 27-30 Sept 2022, Athens
  <a href="https://www.opensips.org/events/Summit-2022Athens/" target="_blank">https://www.opensips.org/events/Summit-2022Athens/</a></pre>
    <div>On 10/11/22 10:29 AM, mayamatakeshi
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div>Hi Bogdan,<br>
        </div>
        <div>indeed, I think I removed the append_branch() line by
          mistake when removing some debug lines I added to check
          function return code etc.</div>
        <div>Thanks,</div>
        <div>Takeshi</div>
        <br>
        <div class="gmail_quote">
          <div dir="ltr" class="gmail_attr">On Mon, Oct 10, 2022 at 9:39
            PM Bogdan-Andrei Iancu <<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>>
            wrote:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
            <div> <font face="monospace">Hi Takeshi,<br>
                <br>
                Aren't you missing the "seturi()" + "append_branch()" in
                the loop ??<br>
                <br>
                Regards,<br>
              </font>
              <pre cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a href="https://www.opensips-solutions.com" target="_blank">https://www.opensips-solutions.com</a>
OpenSIPS Summit 27-30 Sept 2022, Athens
  <a href="https://www.opensips.org/events/Summit-2022Athens/" target="_blank">https://www.opensips.org/events/Summit-2022Athens/</a></pre>
              <div>On 9/28/22 4:26 PM, mayamatakeshi wrote:<br>
              </div>
              <blockquote type="cite">
                <div dir="ltr">
                  <div dir="ltr" class="gmail_attr"><br>
                    On Wed, Sep 28, 2022 at 2:21 PM mayamatakeshi <<a href="mailto:mayamatakeshi@gmail.com" target="_blank">mayamatakeshi@gmail.com</a>>
                    wrote:<br>
                  </div>
                  <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                    <div dir="ltr">
                      <div>Hi, </div>
                      <div>I'm testing latest
                        commit b243666098be44226ade6a7df2b62851efcb5de8
                        of opensips-3.2.</div>
                      <div><br>
                      </div>
                      <div>I tested adding branches to an INVITE for a
                        fixed size list of AORs this way:</div>
                      <div><br>
                      </div>
                                  $var(aors) = "<a href="mailto:sip%3Auser1@test1.com" target="_blank">sip:user1@test1.com</a>,<a href="mailto:sip%3Auser2@test1.com" target="_blank">sip:user2@test1.com</a>,<a href="mailto:sip%3Auser3@test1.com" target="_blank">sip:user3@test1.com</a>";<br>
                      <br>
                                  seturi($(var(aors){s.select,0,,}));<br>
                      <br>
                                  append_branch();<br>
                                  seturi($(var(aors){s.select,1,,}));<br>
                      <br>
                                  append_branch();<br>
                                  seturi($(var(aors){s.select,2,,}));<br>
                      <br>
                                  lookup("location", "r")<br>
                      <br>
                      The above works fine and all 3 destinations
                      resolved by AOR lookup are called (max of contact
                      per AOR).
                      <div><br>
                      </div>
                      <div>However, in case of a a list of unknown size,
                        I tried to use a while loop like this:<br>
                                    $var(aors) = "<a href="mailto:sip%3Auser1@test1.com" target="_blank">sip:user1@test1.com</a>,<a href="mailto:sip%3Auser2@test1.com" target="_blank">sip:user2@test1.com</a>,<a href="mailto:sip%3Auser3@test1.com" target="_blank">sip:user3@test1.com</a>";<br>
                        <br>
                                    $var(idx) = 0;<br>
                                    $var(aor) =
                        $(var(aors){s.select,$var(idx),,});<br>
                        <br>
                                    while($var(aor) != null) {<br>
                                        seturi($var(aor));<br>
                        <br>
                                        $var(idx) = $var(idx) + 1;<br>
                                        $var(aor) =
                        $(var(aors){s.select,$var(idx),,});<br>
                                    }<br>
                        <br>
                                    lookup("location", "r")<br>
                      </div>
                      <div><br>
                      </div>
                      <div>But with the above, only the last destination
                        (lookup of <a href="mailto:user3@test1.com" target="_blank">user3@test1.com</a>)
                        is called.</div>
                      <div>I confirmed this is not related to the lookup
                        function because I tried with fixed destinations
                        like this:</div>
                      <div><br>
                      </div>
                      <div>            $var(aors) = "<a href="http://sip:user1@10.0.0.1:5072/" target="_blank">sip:user1@10.0.0.1:5072</a>,<a href="http://sip:user2@10.0.0.1:5074/" target="_blank">sip:user2@10.0.0.1:5074</a>,<a href="http://sip:user3@10.0.0.1:5076/" target="_blank">sip:user3@10.0.0.1:5076</a>";<br>
                        <br>
                                    $var(idx) = 0;<br>
                                    $var(aor) =
                        $(var(aors){s.select,$var(idx),,});<br>
                        <br>
                                    while($var(aor) != null) {<br>
                                        seturi($var(aor));<br>
                        <br>
                                        $var(idx) = $var(idx) + 1;<br>
                                        $var(aor) =
                        $(var(aors){s.select,$var(idx),,});<br>
                                    }<br>
                        <br>
                      </div>
                      <div>and the same problem happens: only the last
                        destination <a href="http://sip:user3@10.0.0.1:5076/" target="_blank">sip:user3@10.0.0.1:5076</a> is
                        called.</div>
                      <div><br>
                      </div>
                      <div>So, is there a way to append a non-fixed
                        number of branches to an INVITE?</div>
                      <div><br>
                      </div>
                      <div>Regards,</div>
                      <div>Takeshi</div>
                    </div>
                  </blockquote>
                  <div><br>
                  </div>
                  <div>Sorry, I think I did something wrong. </div>
                  <div>I was able to make append_branch to work inside a
                    while loop.</div>
                  <div>So there is no problem.</div>
                  <div>Regards,</div>
                  <div>Takeshi</div>
                  <div><br>
                  </div>
                </div>
                <br>
                <fieldset></fieldset>
                <pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
              </blockquote>
              <br>
            </div>
          </blockquote>
        </div>
      </div>
    </blockquote>
    <br>
  </div>

</blockquote></div></div>