[Freeswitch-users] how to access session variables after hangup???

ivdreg ivdreg ivdreg at gmail.com
Wed Mar 17 04:03:42 PDT 2010


Hi this is a little example from my perl code that do that:

array random_be contains randomized IP addresses of next hops.
there also hash:
my %hunt_error=(
        NO_USER_RESPONSE => 1,
        NETWORK_OUT_OF_ORDER => 1,
        DESTINATION_OUT_OF_ORDER => 1,
        SYSTEM_SHUTDOWN => 1,
);

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.

for (my $i=0;$i <= scalar(@random_be) ; $i++) {
        my $dst_gw = shift(@random_be);
        print "GW:[$dst_gw]\n";
        $bridge = "sofia/internal_out/$called\@$dst_gw";
        $session->execute('bridge',"$bridge");
        $berror = $session->getVariable("originate_disposition");
        if (defined($berror)){
                fprint("\tBridge Error - Check continue or not\n");
                if (!defined($hunt_error{$berror})){
                        fprint("\t HANGUP - ERROR NOT DEFINED");

$session->execute('export','continue_on_fail=false');
                        $session->hangup();
                        return (1);
                }
        } else { last; } ;  ### NO originate_disposition so successful
bridge
}

Suppose this will help. Not in Lua but idea is the same.

Cheers


2010/3/14 rentmycoder rentmycoder <rentmycoder at gmail.com>

> > Pass them as arguments to your luarun hangup hook.
> And what about variables are not available before the call setup (like
> uuid), only during the call progress or after the hangup???
> I would need to access the originate_disposition variable...
>
> >> 'luarun hangup.lua ${originate_disposition}'
> >> 2010-03-14 18:25:08.122511 [CRIT] switch_channel.c:759 Invalid data
> (${api_hangup_hook} contains a variable)
> any other hint???
>
>
> > ---------- Forwarded message ----------
> > From: Brian West <brian at freeswitch.org>
> > To: freeswitch-users at lists.freeswitch.org
> > Date: Sun, 14 Mar 2010 13:00:10 -0500
> > Subject: Re: [Freeswitch-users] how to access session variables after
> hangup???
> > Pass them as arguments to your luarun hangup hook.
> >
> > /b
> >
> > On Mar 14, 2010, at 12:40 PM, rentmycoder rentmycoder wrote:
> >
> >> Hi guys,
> >> Freeswitch rocks!
> >> except the documentation:(
> >> I'm not able to figure out how to access session variables after
> hangup...
> >> I try to dial out on a gateway and detect it the called party hangs up
> >> before bridge...
> >>
> >> bgapi originate
> >>
> {ignore_early_media=true,continue_on_fail=true,bypass_media=false,hangup_after_bridge=true,originate_timeout=10,api_hangup_hook='luarun
> >> hangup.lua ${uuid}'}sofia/gateway/phoneno &park()
> >>
> >> I cannot access the variables using:
> >> 1. script arguments:
> >> 'luarun hangup.lua ${uuid}'}
> >> 2010-03-14 18:25:08.122511 [CRIT] switch_channel.c:759 Invalid data
> >> (${api_hangup_hook} contains a variable)
> >>
> >> 2. session:getVariable("originate_disposition")
> >> 2010-03-14 18:31:37.042756 [ERR] mod_lua.cpp:182 hangup.lua:2: attempt
> >> to call global 'getVar' (a nil value)
> >>
> >> 3. params:getHeader("variable_sip_req_uri")
> >> 2010-03-14 18:36:19.973939 [ERR] mod_lua.cpp:182 hangup.lua:3: attempt
> >> to index global 'params' (a nil value)
> >>
> >> I have asked this before on the dev list too, but Anthony didn't gave
> >> me a clean answer here:
> >>
> http://lists.freeswitch.org/pipermail/freeswitch-dev/2009-July/002491.html
> >>
> >> "In the script you can access the data from the env event which is
> >> automatically created for you and it
> >> contains all the channel variables from that departed channel."
> >>
> >> Ok, but how?????
> >>
> >> Please help...
> >>
>
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100317/d8fd878a/attachment-0002.html 


More information about the FreeSWITCH-users mailing list