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

Jaime jaimecm at gmail.com
Sat Dec 20 02:22:11 MSK 2014


Hi David,
Many Thanks for the tip, I¹m tested it and work fine in 1.4.

Merry Christmas to you and everyone.
Jaime

From:  David Witham <david.witham at netsip.com.au>
Reply-To:  FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
Date:  martes, 16 de diciembre de 2014, 4:43
To:  FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
Subject:  Re: [Freeswitch-users] Hoot get variables in a LUA Hook Event.

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
_________________________________________________________________________
Professional FreeSWITCH Consulting Services: consulting at freeswitch.org
http://www.freeswitchsolutions.com Official FreeSWITCH Sites
http://www.freeswitch.org http://confluence.freeswitch.org
http://www.cluecon.com 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/20141219/38177750/attachment.html 


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