<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;">Hi David,</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;"><span class="Apple-tab-span" style="white-space:pre">        </span>Many Thanks for the tip, I’m tested it and work fine in 1.4.</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;"><br></div><div><font face="Calibri,sans-serif">Merry Christmas to you and everyone.</font></div><div>Jaime</div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;"><br></div><span id="OLK_SRC_BODY_SECTION" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;"><div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span style="font-weight:bold">From: </span> David Witham <<a href="mailto:david.witham@netsip.com.au">david.witham@netsip.com.au</a>><br><span style="font-weight:bold">Reply-To: </span> FreeSWITCH Users Help <<a href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</a>><br><span style="font-weight:bold">Date: </span> martes, 16 de diciembre de 2014, 4:43<br><span style="font-weight:bold">To: </span> FreeSWITCH Users Help <<a href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</a>><br><span style="font-weight:bold">Subject: </span> Re: [Freeswitch-users] Hoot get variables in a LUA Hook Event.<br></div><div><br></div><div><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><style type="text/css" id="owaParaStyle" style="display: none;">P {margin-top:0;margin-bottom:0;}</style><div dir="ltr" fpstyle="1" aria-label="Message body" tabindex="0"><div name="divtagdefaultwrapper" id="divtagdefaultwrapper" style="font-family: Calibri,Arial,Helvetica,sans-serif;font-size: 12pt;color: #000000;margin: 0;">
Hi Jamie,
<div><br></div><div>What we have done is add these lines in the dialplan:</div><div><br></div><div><action application="set" data="session_in_hangup_hook=true"/></div><div><action application="set" data="api_hangup_hook=lua myscript.lua"/></div><div><br></div><div>Then in <FSROOT>/scripts/myscript.lua:</div><div><br></div><div>cdr_uuid = session:getVariable("cdr_uuid");</div><div><br></div><div>This is on a FreeSWITCH 1.2 box. Hope this helps.</div><div><br></div><div>regards,</div><div>David<br><div style="color: rgb(40, 40, 40);"><hr tabindex="-1" style="display:inline-block; width:98%"><div id="divRplyFwdMsg" dir="ltr"><font face="Calibri,sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> <a href="mailto:freeswitch-users-bounces@lists.freeswitch.org">freeswitch-users-bounces@lists.freeswitch.org</a> on behalf of Jaime<br><b>Sent:</b> Tuesday, 16 December 2014 13:04<br><b>To:</b> <a href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</a><br><b>Subject:</b> [Freeswitch-users] Hoot get variables in a LUA Hook Event.</font><div> </div></div><div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px">Hello,</div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><br></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px">I’m trying to use the Hook event’s with LUA script’s when the channel Hangup a call,</div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px">but I’m unable to get the variables, for example uuid, ani or billed seconds for the call,</div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px">I’m using freeswitch 1.4.13 on Centos 6.6 and my configuration is:</div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><br></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px">In /autoload_configs/lua.conf.xml</div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px">[…]</div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><font face="Calibri,sans-serif"> <hook event="CHANNEL_HANGUP_COMPLETE" script="catch-event-cdr1.lua"/></font></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><br></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px">In my catch-event-cdr1.lua script I wrote:</div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"> ses = freeswitch.Session();</div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><div><font face="Calibri,sans-serif"> my_uuid = ses:getVariable("uuid");</font></div><div><font face="Calibri,sans-serif"> freeswitch.consoleLog("notice"," uuid=("..my_uuid..")\n")</font></div></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><br></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px">But I’m get the following error:</div><div><div><font face="Calibri,sans-serif"> 2014-12-15 23:51:46.100755 [ERR] switch_cpp.cpp:724 session is not initalized</font></div><div><font face="Calibri,sans-serif"> 2014-12-15 23:51:46.100755 [NOTICE] switch_cpp.cpp:1328 uuid=()</font></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><br></div></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px">Also, in the wiki doc I see a reference for the “env” Object, (<a href="https://wiki.freeswitch.org/wiki/Mod_lua#Special_Case:_env_object">https://wiki.freeswitch.org/wiki/Mod_lua#Special_Case:_env_object</a>)
but if I call it as the example in the same lua script my result is:</div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><br></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px">How I call the env variable:</div><div><div><font face="Calibri,sans-serif"> dat = env:serialize()</font></div><div><font face="Calibri,sans-serif"> freeswitch.consoleLog("INFO","Here's everything:\n" .. dat .. "\n”)</font></div></div><div><font face="Calibri,sans-serif"><br></font></div><div><div>And I got the following error:</div><div><font face="Calibri,sans-serif"> 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)</font></div></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><br></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><br></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><font face="Calibri,sans-serif">Your help will be appreciated.</font></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><br></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><br></div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px">—</div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px">Jamie</div><div style="color:rgb(0,0,0); font-family:Calibri,sans-serif; font-size:14px"><a href="mailto:Jaimecm@gmail.com">Jaimecm@gmail.com</a></div><span id="OLK_SRC_BODY_SECTION" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;"></span></div></div></div></div></div></div>
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a>
<a href="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</a>
Official FreeSWITCH Sites
<a href="http://www.freeswitch.org">http://www.freeswitch.org</a>
<a href="http://confluence.freeswitch.org">http://confluence.freeswitch.org</a>
<a href="http://www.cluecon.com">http://www.cluecon.com</a>
FreeSWITCH-users mailing list
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a>
<a href="http://www.freeswitch.org">http://www.freeswitch.org</a></span></body></html>