<br><br><div class="gmail_quote">On Mon, Nov 16, 2009 at 9:36 AM, Jerry Richards <span dir="ltr"><<a href="mailto:jerry.richards@teotech.com">jerry.richards@teotech.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
I have a bit of confusion about Lua scripting. When a script is invoked,<br>
should it always return an XML string that is used by FS? Or as in the case<br>
of dialplan examples, does it actually execute the dialplan (e.g.<br>
"session:answer();")?<br>
<br>
Best Regards,<br>
Jerry<br>
<br></blockquote><br>Jerry,<br><br>A Lua script that is explicitly called from the dialplan will indeed execute dialplan-ish stuff. For example, let's say you had this in conf/dialplan/default.xml:<br><br><span style="font-family: courier new,monospace;"><extension name="lua sample"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <condition field="destination_number" expression="9876"></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> <action application="lua" data="/path/to/myluascript.lua"/></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </condition></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></extension></span><br><br>Then myluascript.lua has something like:<br>
<br><span style="font-family: courier new,monospace;">--Sample Lua script</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">session:answer()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">session:sleep(1000)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">session:streamFile("/path/to/file.wav")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">session:hangup()</span><br style="font-family: courier new,monospace;"><br>Assuming an otherwise default install, the above Lua script would execute when a caller dialed 9876, or if a call was x-ferred to 9876.<br>
<br>However, if you're wanting to use Lua to serve up a dialplan then it's totally different. Lua is not called from the dialplan; Lua provides the dialplan to FreeSWITCH. This latter case is the scenario discussed in the wiki section you referenced. (<a href="http://wiki.freeswitch.org/wiki/Lua#For_serving_configuration">http://wiki.freeswitch.org/wiki/Lua#For_serving_configuration</a>)<br>
<br>Are you trying to use Lua scripting for serving up a dynamic configuration of some sort?<br>-MC<br><br><br></div>