I&#39;ve done it ;) <br><br><div>This is what i did:</div><div><br></div><div>In the Macro:</div><div><br></div><div><div>[macro-check-call-limit-mercurios]</div><div>exten =&gt; s,1,Set(group_name=out_calls_user_${SIPCHANINFO(peername)})</div>
<div>exten =&gt; s,n,Set(GROUP()=${group_name})</div><div>exten =&gt; s,n,GotoIf($[${GROUP_COUNT(${group_name})} &gt; ${MAX_OUT_CALLS_PER_USER}]?forbidden,1)</div><div>; EXITO:</div><div>exten =&gt; s,n,MacroExit</div><div>
; FRACASO:</div><div>exten =&gt; forbidden,1,NoOp(*** llamada saliente bloqueada: el usuario ${SIPCHANINFO(peername)} tiene actualmente ${MATH(${GROUP_COUNT(${group_name})})-1,int)} llamadas salientes)</div><div>exten =&gt; forbidden,n,Set(toagi=1);en este caso la llamada no la cuelga la macro como en endpoints la cuelga el agi.</div>
<div>exten =&gt; forbidden,n,Hangup()</div></div><div><br></div><div>Then, in the AGI:</div><div><br></div><div>AGI:</div><div><br></div><div><div>$AGI-&gt;exec(Macro,&quot;check-call-limit-mercurios&quot;);</div><div>$limitada = $AGI-&gt;get_variable(&#39;toagi&#39;);</div>
<div>if ($limitada eq &#39;1&#39;){</div><div>        $AGI-&gt;verbose(&quot;Superado el limite de llamadas salientes out.agi tira el canal&quot;);</div><div>        $AGI-&gt;hangup($chann);</div><div>                     }</div>
<div>#</div><div>#</div></div><div><br></div><div>By the way, is it necessary to Hangup the Macro if the AGI is already doing this?</div><div><br></div><div>BR ;)</div><div><br><div class="gmail_quote">2010/9/3 Steve Edwards <span dir="ltr">&lt;<a href="http://asterisk.org">asterisk.org</a>@<a href="http://sedwards.com">sedwards.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Thu, 2 Sep 2010, Danny Dias wrote:<br>
<br>
</div><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sorry for my poor explanation...what i&#39;m trying to do is to invoke a Macro from my AGI, like this:<br>
<br>
$agi-&gt;exec(&quot;Macro&quot;,&quot;check-call-limit&quot;);<br>
<br>
If the Macro checks that the group_name is bigger than a number specified for every peer with setvar it should Hangup the call (frobidden,1 in the Gotoif...) but this<br>
is not happening, the AGI always continue with is process and it doesn´t play attention to the Hangup in the macro, the macro is here:<br>
<br>
[macro-check-call-limit]<br>
exten =&gt; s,1,Set(group_name=out_calls_user_${SIPCHANINFO(peername)})<br>
exten =&gt; s,n,Set(GROUP()=${group_name})<br>
exten =&gt; s,n,GotoIf($[${GROUP_COUNT(${group_name})} &gt; ${MAX_OUT_CALLS_PER_USER}] forbidden,1)<br>
; EXITO:<br>
exten =&gt; s,n,MacroExit<br>
; FRACASO:<br>
exten =&gt; forbidden,1,NoOp(*** llamada saliente bloqueada: el usuario ${SIPCHANINFO(peername)} tiene actualmente ${MATH(${GROUP_COUNT(${group_name})})-1,int)} llamadas<br>
salientes)<br>
exten =&gt; forbidden,n,Hangup(21)  ; ISUP 21 = SIP 403 (Forbidden)<br>
</blockquote>
<br></div>
The concept of calling a macro from within an AGI seem convoluted, but may work. I&#39;ve never tried it.<br>
<br>
Any particular reason you don&#39;t want to put the logic of the macro in your AGI?<br><font color="#888888">
<br>
-- <br></font><div><div></div><div class="h5">
Thanks in advance,<br>
-------------------------------------------------------------------------<br>
Steve Edwards       <a href="mailto:sedwards@sedwards.com" target="_blank">sedwards@sedwards.com</a>      Voice: +1-760-468-3867 PST<br>
Newline                                              Fax: +1-760-731-3000</div></div><br>--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
New to Asterisk? Join us for a live introductory webinar every Thurs:<br>
               <a href="http://www.asterisk.org/hello" target="_blank">http://www.asterisk.org/hello</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
   <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br></blockquote></div><br><br clear="all"><br>-- <br>Salu2<br><span></span><br>

</div>