<div dir="ltr">The problem is I don't have any dialplan here, as I start the lua script with ESL from a different software.</div><div class="gmail_extra"><br><div class="gmail_quote">2015-02-22 22:43 GMT+00:00 Stanislav Sinyagin <span dir="ltr"><<a href="mailto:ssinyagin@gmail.com" target="_blank">ssinyagin@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">the "limit_usage" command should work -- also from fs_cli.<br>
<br>
When the "limit" dialplan application changes the current count, a<br>
corresponding message is printed into debug log, so you should see if<br>
the limit is set correctly during the call.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On Sun, Feb 22, 2015 at 6:04 PM, Zoltán Szabó <<a href="mailto:zoell@zoell.us">zoell@zoell.us</a>> wrote:<br>
> Hi,<br>
><br>
> Thanks but how can I run limit_usage in my case?<br>
><br>
> With this line, the call starts immediately:<br>
> session1 = freeswitch.Session(dial_call_1);<br>
><br>
> So I need to get the usage info before I start a session. I tried this<br>
> before the freeswitch.Session but it always returns 0:<br>
> api = freeswitch.API();<br>
> local count = api:execute("limit_usage", "hash outbound gw-1");<br>
><br>
> I also tied something like this:<br>
><br>
> limit_gateway1 = "hash outbound gw-1 3 originate sofia/gateway/gw-1/" ..<br>
> phone;<br>
> limit_gateway2 = "hash outbound gw-2 3 originate sofia/gateway/gw-2/" ..<br>
> phone;<br>
> limit_gateway3 = "hash outbound gw-3 3 originate sofia/gateway/gw-3/" ..<br>
> phone;<br>
><br>
> session1 = freeswitch.Session();<br>
> session1:execute("limit_execute", limit_gateway1);<br>
> session1:execute("limit_execute", limit_gateway2);<br>
> session1:execute("limit_execute", limit_gateway3);<br>
><br>
> But it says the session is not initialized when it reaches the first<br>
> limit_execute line.<br>
><br>
> And unfortunately I don't have any dialplan here as I initiate my calls from<br>
> the lua script. Am I missing something?<br>
><br>
> Many thanks<br>
><br>
> 2015-02-08 15:25 GMT+00:00 Stanislav Sinyagin <<a href="mailto:ssinyagin@gmail.com">ssinyagin@gmail.com</a>>:<br>
>><br>
>> here's what I do in mod_perl, Lua code will be quite similar:<br>
>><br>
>> $session->execute<br>
>> ('set',<br>
>> sprintf('user_busy=${cond(${limit_usage(hash %s %s)} > 0 ?<br>
>> true:false)}',<br>
>> $domain, $availability_username));<br>
>> my $user_busy = $session->getVariable('user_busy');<br>
>> if( $user_busy eq 'true' )<br>
>> {<br>
>> ......<br>
>><br>
>> also see my blog entry here:<br>
>><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>
>><br>
>><br>
>> On Sun, Feb 8, 2015 at 1:12 PM, Zoltán Szabó <<a href="mailto:zoell@zoell.us">zoell@zoell.us</a>> wrote:<br>
>> > Hi,<br>
>> ><br>
>> > I have a lua script where I do some business logic. After the logic I<br>
>> > call a<br>
>> > number on a gateway, then when the called party picked up, I call an<br>
>> > other<br>
>> > number on a gateway and bridge the two calls. The only problem is that I<br>
>> > have 5 gateways and each can have maximum of 3 calls (so I can have 15<br>
>> > calls<br>
>> > on this system).<br>
>> ><br>
>> > Here is what I have at the moment (simplified version):<br>
>> ><br>
>> > dial_call_1 = "{leg=1}sofia/gateway/gw-1/<a href="tel:0035312345678" value="+35312345678">0035312345678</a>";<br>
>> > dial_call_2 = "{leg=2}sofia/gateway/gw-2/0035387654321";<br>
>> ><br>
>> > session1 = freeswitch.Session(dial_call_1);<br>
>> ><br>
>> > if (session1:ready()) then<br>
>> > session2 = freeswitch.Session(dial_call_2, session1);<br>
>> ><br>
>> > if (session2:ready()) then<br>
>> > freeswitch.bridge(session1, session2);<br>
>> ><br>
>> > if (session2:ready()) then<br>
>> > session2:hangup();<br>
>> > end<br>
>> > end<br>
>> ><br>
>> > if (session1:ready()) then session1:hangup(); end<br>
>> > end<br>
>> ><br>
>> > How can I use the limit application here to set the max concurrent calls<br>
>> > on<br>
>> > my five gateway, each with 3 max calls and distribute outbound calls<br>
>> > between<br>
>> > them?<br>
>> ><br>
>> > Many thanks,<br>
>> > Zoltan<br>
>> ><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><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><br>
><br>
><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><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></div></div></blockquote></div><br></div>