<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font face="monospace">Hi Takeshi,<br>
      <br>
      Aren't you missing the "seturi()" + "append_branch()" in the loop
      ??<br>
      <br>
      Regards,<br>
    </font>
    <pre class="moz-signature" cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a class="moz-txt-link-freetext" href="https://www.opensips-solutions.com">https://www.opensips-solutions.com</a>
OpenSIPS Summit 27-30 Sept 2022, Athens
  <a class="moz-txt-link-freetext" href="https://www.opensips.org/events/Summit-2022Athens/">https://www.opensips.org/events/Summit-2022Athens/</a></pre>
    <div class="moz-cite-prefix">On 9/28/22 4:26 PM, mayamatakeshi
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CABaNFCas27qLY5kM3kStW33vDYz2aS-Lf3c6Wm1KrW-_MjdDug@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr" class="gmail_attr"><br
            class="gmail-Apple-interchange-newline">
          On Wed, Sep 28, 2022 at 2:21 PM mayamatakeshi <<a
            href="mailto:mayamatakeshi@gmail.com" moz-do-not-send="true">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"
              moz-do-not-send="true">sip:user1@test1.com</a>,<a
              href="mailto:sip%3Auser2@test1.com" target="_blank"
              moz-do-not-send="true">sip:user2@test1.com</a>,<a
              href="mailto:sip%3Auser3@test1.com" target="_blank"
              moz-do-not-send="true">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"
                moz-do-not-send="true">sip:user1@test1.com</a>,<a
                href="mailto:sip%3Auser2@test1.com" target="_blank"
                moz-do-not-send="true">sip:user2@test1.com</a>,<a
                href="mailto:sip%3Auser3@test1.com" target="_blank"
                moz-do-not-send="true">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"
                moz-do-not-send="true">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"
                moz-do-not-send="true">sip:user1@10.0.0.1:5072</a>,<a
                href="http://sip:user2@10.0.0.1:5074/" target="_blank"
                moz-do-not-send="true">sip:user2@10.0.0.1:5074</a>,<a
                href="http://sip:user3@10.0.0.1:5076/" target="_blank"
                moz-do-not-send="true">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" moz-do-not-send="true">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 class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>