On Mon, Nov 16, 2009 at 9:36 AM, Jerry Richards
<jerry.richards@teotech.com>
wrote:
I have a bit of confusion about Lua scripting.
When a script is invoked,
should it always return an XML string
that is used by FS? Or as in the case
of dialplan examples, does it
actually execute the dialplan (e.g.
"session:answer();")?
Best
Regards,
Jerry
Jerry,
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:
<extension name="lua
sample"> <condition
field="destination_number" expression="9876"> <action
application="lua" data="/path/to/myluascript.lua"/> </condition></extension>Then
myluascript.lua has something like:
--Sample Lua scriptsession:answer()session:sleep(1000)session:streamFile("/path/to/file.wav")session:hangup()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.
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. (
http://wiki.freeswitch.org/wiki/Lua#For_serving_configuration)
Are
you trying to use Lua scripting for serving up a dynamic configuration of some
sort?
-MC