Search code examples
luafreeswitch

How to access session variables within hangup hook


How we are able to access to the session variables inside lua file which is executed by api_hangup_hook

Currently i have something like

<action application="set" data="session_in_hangup_hook=true"/>
<action application="export" data="nolocal:api_hangup_hook=lua hangup_file.lua"/>

That will execute "hangup_file.lua" when leg_b hangsup. Is there any kind of possibility to access to the session variables of leg_a or leg_b session within that hangup file?

What ever i try, I am getting an error "attempt to index global 'session' (a nil value)".

If its not possible to achieve this for what is the purpose of "session_in_hangup_hook=true"?


Solution

  • The wiki shows that you actually have an env object (but it doesn't mention if this comes from session_in_hangup_hook).

    Info is here: http://wiki.freeswitch.org/wiki/Lua#Special_Case:_env_object