[Freeswitch-users] Hoot get variables in a LUA Hook Event.

David Witham david.witham at netsip.com.au
Tue Dec 16 10:43:48 MSK 2014


Hi Jamie,

What we have done is add these lines in the dialplan:

<action application="set" data="session_in_hangup_hook=true"/>
<action application="set" data="api_hangup_hook=lua myscript.lua"/>

Then in <FSROOT>/scripts/myscript.lua:

cdr_uuid = session:getVariable("cdr_uuid");

This is on a FreeSWITCH 1.2 box. Hope this helps.

regards,
David
________________________________
From: freeswitch-users-bounces at lists.freeswitch.org on behalf of Jaime
Sent: Tuesday, 16 December 2014 13:04
To: freeswitch-users at lists.freeswitch.org
Subject: [Freeswitch-users] Hoot get variables in a LUA Hook Event.

Hello,

I'm trying to use the Hook event's with LUA script's when the channel Hangup a call,
but I'm unable to get the variables, for example uuid, ani or billed seconds for the call,
I'm using freeswitch 1.4.13 on Centos 6.6 and my configuration is:

In /autoload_configs/lua.conf.xml
[...]
    <hook event="CHANNEL_HANGUP_COMPLETE" script="catch-event-cdr1.lua"/>

In my catch-event-cdr1.lua script I wrote:
    ses = freeswitch.Session();
    my_uuid = ses:getVariable("uuid");
    freeswitch.consoleLog("notice","    uuid=("..my_uuid..")\n")

But I'm get the following error:
    2014-12-15 23:51:46.100755 [ERR] switch_cpp.cpp:724 session is not initalized
    2014-12-15 23:51:46.100755 [NOTICE] switch_cpp.cpp:1328     uuid=()

Also, in the wiki doc I see a reference for the "env" Object, (https://wiki.freeswitch.org/wiki/Mod_lua#Special_Case:_env_object) but if I call it as the example in the same lua script my result is:

How I call the env variable:
    dat = env:serialize()
    freeswitch.consoleLog("INFO","Here's everything:\n" .. dat .. "\n")

And I got the following error:
    2014-12-16 00:00:17.440782 [ERR] mod_lua.cpp:203 /usr/share/freeswitch/scripts/catch-event-reg6.lua:27: attempt to index global 'env' (a nil value)


Your help will be appreciated.


-
Jamie
Jaimecm at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20141216/408a8662/attachment-0001.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list