[Freeswitch-users] Hangup hooks on B legs

Isaac Jurado ijurado at econcept.es
Thu Aug 4 13:03:54 MSD 2011


On Wed, Aug 3, 2011 at 7:56 PM, Avi Marcus <avi at avimarcus.net> wrote:
>
> If the channel is hung up, then it's hung up.. that's what the hangup
> hook is, afaik.
> If you look at the wiki page for this:
> http://wiki.freeswitch.org/wiki/Variable_session_in_hangup_hook
> it only says that you can "access" the variable, not that the channel
> still exists or that you can set them.

Ok.  I still have some problems with this.  My dialplan contains the
following:

<action application="export" data="session_in_hangup_hook=true"/>
<action application="export" data="api_hangup_hook=luarun
transfer_check.lua ${uuid}"/>

The transfer_check.lua script is the following:

session = freeswitch.Session(argv[1])
local cause = session:hangupCause()

if cause == "ATTENDED_TRANSFER" or cause == "BLIND_TRANSFER"
then
    api = freeswitch.API()
    api.execute("log",  "NOTICE Transfer detected, billsec is " ..
session:getVariable("billsec"))
end

The problem is that, as already discussed, the channel no longer exists
so the UUID is not referring to anything.

Basically, my question is: How do you obtain the session object in a
hangup hook?

Cheers.

-- 
Isaac Jurado
Internet Busines Solutions eConcept



Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list