Hi this is a little example from my perl code that do that:<br><br>array random_be contains randomized IP addresses of next hops.<br>there also hash:<br>my %hunt_error=(<br> NO_USER_RESPONSE => 1,<br> NETWORK_OUT_OF_ORDER => 1,<br>
DESTINATION_OUT_OF_ORDER => 1,<br> SYSTEM_SHUTDOWN => 1,<br>);<br><br>If error is defined in this array we hunt else drop call. I assume that these errors are internally generated from this FS instance or comes first remote hop. So I need to hunt over next hop. But if error comes from last server I drop call and do not hunt over rest of my SIP servers.<br>
<br>for (my $i=0;$i <= scalar(@random_be) ; $i++) {<br> my $dst_gw = shift(@random_be);<br> print "GW:[$dst_gw]\n";<br> $bridge = "sofia/internal_out/$called\@$dst_gw";<br> $session->execute('bridge',"$bridge");<br>
$berror = $session->getVariable("originate_disposition");<br> if (defined($berror)){<br> fprint("\tBridge Error - Check continue or not\n");<br> if (!defined($hunt_error{$berror})){<br>
fprint("\t HANGUP - ERROR NOT DEFINED");<br> $session->execute('export','continue_on_fail=false');<br> $session->hangup();<br>
return (1);<br> }<br> } else { last; } ; ### NO originate_disposition so successful bridge <br>}<br><br>Suppose this will help. Not in Lua but idea is the same.<br><br>Cheers<br>
<br><br><div class="gmail_quote">2010/3/14 rentmycoder rentmycoder <span dir="ltr"><<a href="mailto:rentmycoder@gmail.com">rentmycoder@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">> Pass them as arguments to your luarun hangup hook.<br>
</div>And what about variables are not available before the call setup (like<br>
uuid), only during the call progress or after the hangup???<br>
I would need to access the originate_disposition variable...<br>
<br>
>> 'luarun hangup.lua ${originate_disposition}'<br>
<div class="im">>> 2010-03-14 18:25:08.122511 [CRIT] switch_channel.c:759 Invalid data (${api_hangup_hook} contains a variable)<br>
</div>any other hint???<br>
<div><div></div><div class="h5"><br>
<br>
> ---------- Forwarded message ----------<br>
> From: Brian West <<a href="mailto:brian@freeswitch.org">brian@freeswitch.org</a>><br>
> To: <a href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</a><br>
> Date: Sun, 14 Mar 2010 13:00:10 -0500<br>
> Subject: Re: [Freeswitch-users] how to access session variables after hangup???<br>
> Pass them as arguments to your luarun hangup hook.<br>
><br>
> /b<br>
><br>
> On Mar 14, 2010, at 12:40 PM, rentmycoder rentmycoder wrote:<br>
><br>
>> Hi guys,<br>
>> Freeswitch rocks!<br>
>> except the documentation:(<br>
>> I'm not able to figure out how to access session variables after hangup...<br>
>> I try to dial out on a gateway and detect it the called party hangs up<br>
>> before bridge...<br>
>><br>
>> bgapi originate<br>
>> {ignore_early_media=true,continue_on_fail=true,bypass_media=false,hangup_after_bridge=true,originate_timeout=10,api_hangup_hook='luarun<br>
>> hangup.lua ${uuid}'}sofia/gateway/phoneno &park()<br>
>><br>
>> I cannot access the variables using:<br>
>> 1. script arguments:<br>
>> 'luarun hangup.lua ${uuid}'}<br>
>> 2010-03-14 18:25:08.122511 [CRIT] switch_channel.c:759 Invalid data<br>
>> (${api_hangup_hook} contains a variable)<br>
>><br>
>> 2. session:getVariable("originate_disposition")<br>
>> 2010-03-14 18:31:37.042756 [ERR] mod_lua.cpp:182 hangup.lua:2: attempt<br>
>> to call global 'getVar' (a nil value)<br>
>><br>
>> 3. params:getHeader("variable_sip_req_uri")<br>
>> 2010-03-14 18:36:19.973939 [ERR] mod_lua.cpp:182 hangup.lua:3: attempt<br>
>> to index global 'params' (a nil value)<br>
>><br>
>> I have asked this before on the dev list too, but Anthony didn't gave<br>
>> me a clean answer here:<br>
>> <a href="http://lists.freeswitch.org/pipermail/freeswitch-dev/2009-July/002491.html" target="_blank">http://lists.freeswitch.org/pipermail/freeswitch-dev/2009-July/002491.html</a><br>
>><br>
>> "In the script you can access the data from the env event which is<br>
>> automatically created for you and it<br>
>> contains all the channel variables from that departed channel."<br>
>><br>
>> Ok, but how?????<br>
>><br>
>> Please help...<br>
>><br>
<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>
</div></div></blockquote></div><br>