<div dir="ltr">Liviu,<div><br></div><div><br>Thanks for your reply. To preface my forthcoming I&#39;d like to state at the current moment the reply to this query is pretty quick. If the request was to take X amount time the script would continue even though a condition is based on it advancing? The reason I ask is because I notice the async method was added with the intention of pausing the script until the reply is received. What is the timeout that would make opensips continue on with the script?</div><div><br></div><div><br>Thanks,</div><div>Tito</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 17, 2015 at 3:36 AM, Liviu Chircu <span dir="ltr">&lt;<a href="mailto:liviu@opensips.org" target="_blank">liviu@opensips.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <tt>Hi Tito,<br>
      <br>
      A very interesting question. After a bit of research, I can tell
      you that $json and $var will behave quite similarly in terms of
      performance when using the simple &quot;=&quot; (assign) operator. A
      difference between them worth pointing out is that $var uses
      only-pkg memory, while $json uses both pkg and system memory
      (since it is based on the &quot;json-c&quot; library) - so the more $json&#39;s
      you fill up, the more &quot;opensipsctl fifo get_statistics pkmem:&quot;
      will be incorrect.<br>
      <br>
      If you really want to optimize something about that _specific_
      code:<br>
    </tt><tt><span><br>
        $json(authbody) :=</span><span> $json(authresponse)</span><span>;</span></tt><br>
    <tt><span><span>if ($json(authbody/message/AcceptCall)
          =</span><span>= &quot;false&quot;) {<br>
              ...<br>
          }</span></span><br>
      <br>
      Best regards,<br>
    </tt>
    <pre cols="72">Liviu Chircu
OpenSIPS Developer
<a href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a></pre><div><div class="h5">
    <div>On 17.06.2015 02:18, Tito Cumpen wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="h5">
      <div dir="ltr">Group,
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Is there a downside to casting responses from a rest
          response into a json object rather than a generic $var? Here
          is my function it works but I want to be aware if this will
          cost a considerable amount of resources.</div>
        <div><br>
        </div>
        <div>
          <p><span>                      if
              (!rest_get(&quot;http:</span><span>//<a href="http://myauthurl.com/authme/$fU/$rU" target="_blank">myauthurl.com/authme/$fU/$rU</a>&quot;,
              &quot;$json(authresponse)&quot;, &quot;$var(ct)&quot;, &quot;$var(rcode)&quot;)) {</span></p>
          <p><span></span><br>
          </p>
          <p><span>        xlog(&quot;Error code
              $var(rcode) in HTTP GET!\n&quot;)</span><span>;</span></p>
          <p><span>xlog(&quot;on account of admittance
              error we are sending the call to the AS server for
              processing&quot;)</span><span>;</span><br>
            <span></span></p>
          <p><span>        route(4)</span><span>;</span></p>
          <p><span>}</span></p>
          <p><span></span><br>
          </p>
          <p><span>                xlog(&quot;got this body
              response from authority on invite $json(authresponse) with
              response code $var(rcode)&quot;)</span><span>;</span></p>
          <p><span>        xlog(&quot;response now casting
              to json  $json(authresponse) &quot;)</span><span>;</span></p>
          <p><span>        $json(authbody) :=</span><span> &quot;{}&quot;</span><span>;</span></p>
          <p><span></span><br>
          </p>
          <p><span>        $json(authbody) :=</span><span> $json(authresponse)</span><span>;</span></p>
          <p><span>        xlog(&quot; accessing the
              message $json(authbody/message)&quot;)</span><span>;</span></p>
          <p><span></span><br>
          </p>
          <p><span>        $json(accept) :=</span><span>  $json(authbody/message)</span><span>;</span><br>
          </p>
          <p><span>        xlog(&quot; casted message
              $json(accept)&quot;)</span><span>;</span></p>
          <p><span>        if($json(accept/AcceptCall)
              =</span><span>= &quot;false&quot;){         </span><br>
          </p>
          <p><span>        xlog(&quot;response equal
              false&quot;)</span><span>;</span></p>
          <p><span>                                   
                                          route(3)</span><span>;</span></p>
          <p><span></span><br>
          </p>
          <p><span></span><br>
          </p>
          <p><span>        }else{</span></p>
          <p><span><br>
            </span></p>
          <p><span><br>
            </span></p>
          <p><span>Notice how the response is casted
              from </span><span>$json(authresponse) to </span> $json(authbody) 
            after it is initialized. I came to realize that I had to
            initialize a variable because I couldn&#39;t access keys in <span> </span><span>$json(authresponse).</span></p>
          <p><span><br>
            </span></p>
          <p><span><br>
            </span></p>
          <p><span>Thanks,</span></p>
          <p><span>Tito</span></p>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><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>

<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br></div>