I'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 => s,1,Set(group_name=out_calls_user_${SIPCHANINFO(peername)})</div>
<div>exten => s,n,Set(GROUP()=${group_name})</div><div>exten => s,n,GotoIf($[${GROUP_COUNT(${group_name})} > ${MAX_OUT_CALLS_PER_USER}]?forbidden,1)</div><div>; EXITO:</div><div>exten => s,n,MacroExit</div><div>
; FRACASO:</div><div>exten => forbidden,1,NoOp(*** llamada saliente bloqueada: el usuario ${SIPCHANINFO(peername)} tiene actualmente ${MATH(${GROUP_COUNT(${group_name})})-1,int)} llamadas salientes)</div><div>exten => 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 => 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->exec(Macro,"check-call-limit-mercurios");</div><div>$limitada = $AGI->get_variable('toagi');</div>
<div>if ($limitada eq '1'){</div><div> $AGI->verbose("Superado el limite de llamadas salientes out.agi tira el canal");</div><div> $AGI->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"><<a href="http://asterisk.org">asterisk.org</a>@<a href="http://sedwards.com">sedwards.com</a>></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'm trying to do is to invoke a Macro from my AGI, like this:<br>
<br>
$agi->exec("Macro","check-call-limit");<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 => s,1,Set(group_name=out_calls_user_${SIPCHANINFO(peername)})<br>
exten => s,n,Set(GROUP()=${group_name})<br>
exten => s,n,GotoIf($[${GROUP_COUNT(${group_name})} > ${MAX_OUT_CALLS_PER_USER}] forbidden,1)<br>
; EXITO:<br>
exten => s,n,MacroExit<br>
; FRACASO:<br>
exten => forbidden,1,NoOp(*** llamada saliente bloqueada: el usuario ${SIPCHANINFO(peername)} tiene actualmente ${MATH(${GROUP_COUNT(${group_name})})-1,int)} llamadas<br>
salientes)<br>
exten => 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've never tried it.<br>
<br>
Any particular reason you don'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>