[Freeswitch-users] Accessing Config Info From Database

Michael Collins msc at freeswitch.org
Mon Nov 16 11:33:09 PST 2009


On Mon, Nov 16, 2009 at 9:36 AM, Jerry Richards
<jerry.richards at 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 script
session: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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20091116/c73ec21e/attachment-0002.html 


More information about the FreeSWITCH-users mailing list