<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<tt>Hi Tito,<br>
<br>
Make sure to read all "rest_client" module parameters. In your
case, the async() timeout would be accomplished with the
"curl_timeout" parameter [1]<br>
If that were to happen, "rest_get()" would return a negative
value, and you could catch it just like in the examples. [2]<br>
<br>
[1]:
<a class="moz-txt-link-freetext" href="http://www.opensips.org/html/docs/modules/2.2.x/rest_client.html#id249608">http://www.opensips.org/html/docs/modules/2.2.x/rest_client.html#id249608</a><br>
[2]:
<a class="moz-txt-link-freetext" href="http://www.opensips.org/html/docs/modules/2.2.x/rest_client.html#id293823">http://www.opensips.org/html/docs/modules/2.2.x/rest_client.html#id293823</a><br>
<br>
Best regards,<br>
</tt>
<pre class="moz-signature" cols="72">Liviu Chircu
OpenSIPS Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a></pre>
<div class="moz-cite-prefix">On 18.06.2015 00:47, Tito Cumpen wrote:<br>
</div>
<blockquote
cite="mid:CANZPVB5sd=BZTQP_xZX4eTSRdfn-kUmVMvNgKy0rOEkR1cEV4A@mail.gmail.com"
type="cite">
<div dir="ltr">Liviu,
<div><br>
</div>
<div><br>
Thanks for your reply. To preface my forthcoming I'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"><<a moz-do-not-send="true"
href="mailto:liviu@opensips.org" target="_blank">liviu@opensips.org</a>></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
"=" (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 "json-c" library) - so the more $json's you fill
up, the more "opensipsctl fifo get_statistics pkmem:"
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>=
"false") {<br>
...<br>
}</span></span><br>
<br>
Best regards,<br>
</tt>
<pre cols="72">Liviu Chircu
OpenSIPS Developer
<a moz-do-not-send="true" 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("http:</span><span>//<a
moz-do-not-send="true"
href="http://myauthurl.com/authme/$fU/$rU"
target="_blank">myauthurl.com/authme/$fU/$rU</a>",
"$json(authresponse)", "$var(ct)",
"$var(rcode)")) {</span></p>
<p><span></span><br>
</p>
<p><span> xlog("Error code $var(rcode) in
HTTP GET!\n")</span><span>;</span></p>
<p><span>xlog("on account of admittance error we
are sending the call to the AS server for
processing")</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("got this body
response from authority on invite
$json(authresponse) with response code
$var(rcode)")</span><span>;</span></p>
<p><span> xlog("response now casting to
json $json(authresponse) ")</span><span>;</span></p>
<p><span> $json(authbody) :=</span><span>
"{}"</span><span>;</span></p>
<p><span></span><br>
</p>
<p><span> $json(authbody) :=</span><span>
$json(authresponse)</span><span>;</span></p>
<p><span> xlog(" accessing the message
$json(authbody/message)")</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(" casted message
$json(accept)")</span><span>;</span></p>
<p><span> if($json(accept/AcceptCall) =</span><span>=
"false"){ </span><br>
</p>
<p><span> xlog("response equal false")</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'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 moz-do-not-send="true" href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a moz-do-not-send="true" 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 moz-do-not-send="true"
href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a moz-do-not-send="true"
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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<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>