<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.24.1.1">
</HEAD>
<BODY>
Hi<BR>
I dont know about events so much but I cannot see variable "e" is setting<BR>
<BR>
<B>event_name = e:getHeader("Event-Name") or "" </B><BR>
<B>event_subclass = e:getHeader("Event-Subclass") or "" </B><BR>
<BR>
regurds<BR>
Eli<BR>
<BR>
On Thu, 2009-08-06 at 12:58 +0300, Seven Du wrote:<BR>
<BLOCKQUOTE TYPE=CITE>
ALL-
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
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.
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
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.
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
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 ?
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
3) Any way to show how many running lua scripts? luashow ?
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
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].
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
5) Seems that only EventConsumer("all") working. EventConsumer("CHANNEL_HANUP CUSTOM lua::stop") doesn't seem to work. Any idea to this?
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
Thanks a lot.
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
code example:
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
con = freeswitch.EventConsumer("all");
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
argv[0] = "test.lua"
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
freeswitch.consoleLog("info", "==== Lua Script [" .. argv[0] .. "] Starting =====\n");
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
local all_events = 0
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
for e in (function() return con:pop(1) end) do
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
-- freeswitch.consoleLog("info", "event\n" .. e:serialize("xml"));
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
all_events = all_events + 1;
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
freeswitch.consoleLog("info", "all_events: " .. all_events .. "\n")
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
event_name = e:getHeader("Event-Name") or ""
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
event_subclass = e:getHeader("Event-Subclass") or ""
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
if (event_name == "CUSTOM" and event_subclass == "lua::stop") then
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
freeswitch.consoleLog("info", "-----lua Script [" .. argv[0] .. "]---Exiting------\n")
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
break
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
end
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
end
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<BR>
</BLOCKQUOTE>
</BODY>
</HTML>