[Freeswitch-users] Lua session originate - freeswitch crash

Anthony Minessale anthony.minessale at gmail.com
Wed Apr 13 19:32:38 MSD 2011


I didn't say you can't use LUA The only point I was trying to make is:


if you are running the lua script on an inbound call, then you just
create a new session and ignore the one the call came in on you have
an issue.

lua is best when you are trying to make an IVR or do advanced logic
that is too much for the XML dialplan.
You have a single channel and you use the channel data to do things on
that channel.

One big mistake people tend to make is they think that embedded
scripting is a shortcut to making complex apps without thinking
through the requirements.

Also doing things like trying to setup and bridge 2 channels together
in lua manually is unwise.  The originate syntax is the same
everywhere including with the bridge app.  The best thing to do is use
your script to figure out the params you need for the originate syntax
of the B leg then simply set that as a variable, exit the script and
pass that variable to the bridge app from your dialplan.

If you need to be fully asynchronous you for sure want to consider ESL.





On Wed, Apr 13, 2011 at 10:01 AM, Michael Collins <msc at freeswitch.org> wrote:
>
>
> On Wed, Apr 13, 2011 at 6:59 AM, Eric Beard <eric at loopfx.com> wrote:
>>
>> I've been fiddling around with things this morning and I am using a
>> combination of PHP and Lua.
>>
>> I use php to simply originate the call (using regular sockets to talk to
>> 8021, not the php mod for ESL, since I can't get it to compile).  In the
>> originate command I specify a Lua script that handles the rest of the call.
>>
>> I'm using the PHP functions described here:
>>
>> http://wiki.freeswitch.org/wiki/PHP_Event_Socket
>>
>> My PHP:
>>
>>
>>  $fp = event_socket_create("127.0.0.1", 8021, "ClueCon");
>>  $channelVars =
>> "{ignore_early_media=true,origination_caller_id_number=18778502010}";
>>  $phoneNum = "17277762768";
>>  $notificationId = "x";
>>  $cmd = "bgapi originate $channelVars".
>>   "sofia/gateway/affinity/".$phoneNum." &lua('test2.lua
>> $notificationId')";
>>  echo "Sending command: $cmd";
>>  $response = event_socket_request($fp, $cmd);
>>  echo $response;
>>  fclose($fp);
>>
>> My Lua:
>>
>>
>> prompt = "/home/eric/test1.wav"
>> session:streamFile(prompt)
>> session:hangup()
>>
>> This is working for the very basic scenario of just waiting for the number
>> to pick up, playing a wav, and then hanging up.  If anybody can point out
>> any major showstoppers that would prevent me from handling significant user
>> interaction, I'd love to hear about them now.  One of the things I'd like to
>> do is incorporate pocketsphinx so that I can do voice reco.  Is that
>> possible from Lua?
>
> You can run pretty much any dialplan application from Lua using the
> session:execute method. I don't see any issues with you originating the
> calls via event socket and then handling the answered calls with a Lua dp
> script.
> -MC
> _______________________________________________
> 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
>
>



-- 
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/
Twitter: http://twitter.com/FreeSWITCH_wire

AIM: anthm
MSN:anthony_minessale at hotmail.com
GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888 at conference.freeswitch.org
googletalk:conf+888 at conference.freeswitch.org
pstn:+19193869900



More information about the FreeSWITCH-users mailing list