<div dir="ltr">Hi,<div><br></div><div>Thanks but how can I run limit_usage in my case? </div><div><br></div><div>With this line, the call starts immediately:</div><div><span style="font-family:monospace,monospace;font-size:12.8000001907349px">session1 = freeswitch.Session(dial_call_</span><span style="font-family:monospace,monospace;font-size:12.8000001907349px">1);</span><br></div><div><span style="font-family:monospace,monospace;font-size:12.8000001907349px"><br></span></div><div>So I need to get the usage info before I start a session. I tried this before the freeswitch.Session but it always returns 0:</div><div>api = freeswitch.API();</div><div>local count = api:execute(&quot;limit_usage&quot;, &quot;hash outbound gw-1&quot;);<br></div><div><br></div><div>I also tied something like this:</div><div><br></div><div><div><font face="monospace, monospace">    limit_gateway1 = &quot;hash outbound gw-1 3 originate sofia/gateway/gw-1/&quot; .. phone;</font></div><div><font face="monospace, monospace">    limit_gateway2 = &quot;hash outbound gw-2 3 originate sofia/gateway/gw-2/&quot; .. phone;</font></div><div><font face="monospace, monospace">    limit_gateway3 = &quot;hash outbound gw-3 3 originate sofia/gateway/gw-3/&quot; .. phone;</font></div><div><font face="monospace, monospace"><br></font></div><div><div><font face="monospace, monospace">    session1 = freeswitch.Session();</font></div><div><font face="monospace, monospace">    session1:execute(&quot;limit_execute&quot;, limit_gateway1);</font></div><div><font face="monospace, monospace">    session1:execute(&quot;limit_execute&quot;, limit_gateway2);</font></div><div><font face="monospace, monospace">    session1:execute(&quot;limit_execute&quot;, limit_gateway3);</font></div></div><div><br></div><div>But it says the session is not initialized when it reaches the first limit_execute line.</div><div><br></div><div>And unfortunately I don&#39;t have any dialplan here as I initiate my calls from the lua script. Am I missing something?</div><div><br><div>Many thanks</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-02-08 15:25 GMT+00:00 Stanislav Sinyagin <span dir="ltr">&lt;<a href="mailto:ssinyagin@gmail.com" target="_blank">ssinyagin@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">here&#39;s what I do in mod_perl, Lua code will be quite similar:<br>
<br>
    $session-&gt;execute<br>
        (&#39;set&#39;,<br>
         sprintf(&#39;user_busy=${cond(${limit_usage(hash %s %s)} &gt; 0 ?<br>
true:false)}&#39;,<br>
                 $domain, $availability_username));<br>
    my $user_busy = $session-&gt;getVariable(&#39;user_busy&#39;);<br>
    if( $user_busy eq &#39;true&#39; )<br>
    {<br>
......<br>
<br>
also see my blog entry here:<br>
<a href="https://txlab.wordpress.com/2013/06/29/freeswitch-limiting-the-number-of-concurrent-calls-on-multiple-sip-accounts/" target="_blank">https://txlab.wordpress.com/2013/06/29/freeswitch-limiting-the-number-of-concurrent-calls-on-multiple-sip-accounts/</a><br>
<div><div class="h5"><br>
<br>
On Sun, Feb 8, 2015 at 1:12 PM, Zoltán Szabó &lt;<a href="mailto:zoell@zoell.us">zoell@zoell.us</a>&gt; wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; I have a lua script where I do some business logic. After the logic I call a<br>
&gt; number on a gateway, then when the called party picked up, I call an other<br>
&gt; number on a gateway and bridge the two calls. The only problem is that I<br>
&gt; have 5 gateways and each can have maximum of 3 calls (so I can have 15 calls<br>
&gt; on this system).<br>
&gt;<br>
&gt; Here is what I have at the moment (simplified version):<br>
&gt;<br>
&gt; dial_call_1 = &quot;{leg=1}sofia/gateway/gw-1/<a href="tel:0035312345678" value="+35312345678">0035312345678</a>&quot;;<br>
&gt; dial_call_2 = &quot;{leg=2}sofia/gateway/gw-2/0035387654321&quot;;<br>
&gt;<br>
&gt; session1 = freeswitch.Session(dial_call_1);<br>
&gt;<br>
&gt; if (session1:ready()) then<br>
&gt; session2 = freeswitch.Session(dial_call_2, session1);<br>
&gt;<br>
&gt; if (session2:ready()) then<br>
&gt; freeswitch.bridge(session1, session2);<br>
&gt;<br>
&gt; if (session2:ready()) then<br>
&gt; session2:hangup();<br>
&gt; end<br>
&gt; end<br>
&gt;<br>
&gt; if (session1:ready()) then session1:hangup(); end<br>
&gt; end<br>
&gt;<br>
&gt; How can I use the limit application here to set the max concurrent calls on<br>
&gt; my five gateway, each with 3 max calls and distribute outbound calls between<br>
&gt; them?<br>
&gt;<br>
&gt; Many thanks,<br>
&gt; Zoltan<br>
&gt;<br>
</div></div>&gt; _________________________________________________________________________<br>
&gt; Professional FreeSWITCH Consulting Services:<br>
&gt; <a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
&gt; <a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
&gt;<br>
&gt; Official FreeSWITCH Sites<br>
&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
&gt; <a href="http://confluence.freeswitch.org" target="_blank">http://confluence.freeswitch.org</a><br>
&gt; <a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
&gt;<br>
&gt; FreeSWITCH-users mailing list<br>
&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br>
_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" target="_blank">http://confluence.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a></blockquote></div><br></div></div>