Hello,
please do not write direct private emails for questions about kamailio, use public mailing list sr-users@lists.sip-router.org (cc-ed) -- private emails are ignored, after the first notification.
exit is not a function exported by a module, it is implemented in core.
On the other hand, you try to stop the kamailio cfg interpreter when lua interpreter is executing the Lua script, so it won't work straightforward. Set a variable in kamailio from Lua, then check it after executing the lua script to decide to further exit or not.
Cheers, Daniel
On 5/24/11 11:44 AM, Bret McDanel wrote:
I am having a terrible time trying to get a conditional response from a lua script.
Basically I want
if error then sr.sl.send_reply(404,"Not Found"); sr.modf("exit"); -- this does not work! end
How can I have such a conditional? I have tried with return values from the script to see if that would change anything but that did not seem to work, sr.modf("exit") is not found.
Any assistance would be greatly appreciated.
On Tue, 2011-05-24 at 12:38 +0200, Daniel-Constantin Mierla wrote:
exit is not a function exported by a module, it is implemented in core.
On the other hand, you try to stop the kamailio cfg interpreter when lua interpreter is executing the Lua script, so it won't work straightforward. Set a variable in kamailio from Lua, then check it after executing the lua script to decide to further exit or not.
How does one set a variable and subsequently access it outside of lua? I tried what I thought was correct, but absent any documentation I can find I cant seem to get that to work.
On 5/24/11 8:45 PM, Bret McDanel wrote:
On Tue, 2011-05-24 at 12:38 +0200, Daniel-Constantin Mierla wrote:
exit is not a function exported by a module, it is implemented in core.
On the other hand, you try to stop the kamailio cfg interpreter when lua interpreter is executing the Lua script, so it won't work straightforward. Set a variable in kamailio from Lua, then check it after executing the lua script to decide to further exit or not.
How does one set a variable and subsequently access it outside of lua? I tried what I thought was correct, but absent any documentation I can find I cant seem to get that to work.
For example, setting $var(exit) to 1 from Lua:
sr.pv.seti("$var(exit)", 1)
The function is listed in the Lua API:
http://sip-router.org/wiki/api/lua/devel#srpvseti
Then you can check in Kamailio config:
if($var(exit)==1) exit;
Cheers, Daniel
Bret McDanel writes:
How does one set a variable and subsequently access it outside of lua? I tried what I thought was correct, but absent any documentation I can find I cant seem to get that to work.
there must be some documentation somewhere, since i was able to write a couple of lua functions. here is an example from one script:
sr.pv.sets("$avp(tail)", tail)
tail if lua variable and $avp(tail) is sr variable.
-- juha