Hi
I dont know about events so much but I cannot see variable "e" is setting

event_name = e:getHeader("Event-Name") or ""
event_subclass = e:getHeader("Event-Subclass") or ""

regurds
Eli

On Thu, 2009-08-06 at 12:58 +0300, Seven Du wrote:
ALL-


I have a few questions when scripting lua. According to wiki, it is possible to run looping forever lua scripts through start-up config or luarun. 


1) Will the lua script stop when unload mod_lua? I experienced core dump when unload mod_lua while there was a running lua script. Reported on jira.


2) How to stop a forever running lua script?  I stop it by listening a CUSTOM event fired elsewhere. See code below. Is there any standard way like luastop ?


3) Any way to show how many running lua scripts? luashow ?


4) It seems cannot get the lua script name in a lua script, I made a patch to jira by assign it to the argv[0].


5) Seems that only EventConsumer("all") working. EventConsumer("CHANNEL_HANUP CUSTOM lua::stop") doesn't seem to work. Any idea to this?


Thanks a lot.




                                               
code example:


con = freeswitch.EventConsumer("all");      


argv[0] = "test.lua"
                       
freeswitch.consoleLog("info", "==== Lua Script [" .. argv[0] .. "] Starting =====\n");
                        
local all_events = 0
                                                                                                          
for e in (function() return con:pop(1) end) do
  -- freeswitch.consoleLog("info", "event\n" .. e:serialize("xml"));
   all_events = all_events + 1;
freeswitch.consoleLog("info", "all_events: " .. all_events .. "\n")

event_name = e:getHeader("Event-Name") or ""
event_subclass = e:getHeader("Event-Subclass") or ""

if (event_name == "CUSTOM" and event_subclass == "lua::stop") then
 freeswitch.consoleLog("info", "-----lua Script [" .. argv[0] .. "]---Exiting------\n")
 break
end


end