[Freeswitch-users] A few questions about lua

Seven Du dujinfang at gmail.com
Thu Aug 6 20:45:16 PDT 2009


Sorry it's a typo. I read the code, it works not like in event socket. So,
only works with one event.
either
EventConsumer("all")
or
EventConsumer("CUSTOM", "lua::stop");


Thank you.

2009/8/7 Raffaele P. Guidi <raffaele.p.guidi at gmail.com>

> >> 5) Seems that only EventConsumer("all") working.
> EventConsumer("CHANNEL_HANUP CUSTOM lua::stop") doesn't seem to work. Any
> idea to this?
>
> isn't it CHANNEL_HAN*G*UP? Is the G missing only in the email or in the
> code, too?
>
> On Thu, Aug 6, 2009 at 17:52, Seven Du <dujinfang at gmail.com> wrote:
>
>> for e in (function() return con:pop(1) end) do
>>
>> btw, the script works.
>>
>> Thanks.
>> On Aug 6, 2009, at 6:47 PM, Eli Hayun wrote:
>> > 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
>> >>
>> >>
>> > _______________________________________________
>> > 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
>>
>>
>> _______________________________________________
>> 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
>>
>
>
> _______________________________________________
> 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/20090807/2f742db8/attachment-0002.html 


More information about the FreeSWITCH-users mailing list