[Freeswitch-dev] MOH in async mode is possible?
Hi everyone, I've been trying ways to provide MOH in background of Lua script (searching and found few way) but none of them really satisfied me. I think it may implement in the same way of record_session function. So I need your advises if it is possible or not? It's a really good idea? Thank you! vutamhoan
I believe I already answered this question when you asked on irc. But I'll answer it again so it can be logged. To put it simply you are barking up the wrong tree trying to do asynchronous things from a lua script. Change your paradigm in your brain to think about it more like a GUI loop. You only have 1 thread and you want to make the channel do something by itself in the background but your script is already executing.... If you want this you need 2 threads. There are several ways to get this but you have to choose one. 1) Use ESL and an external application that can be running in your own process so you can perform async operations. 2) Send the channel to the "park" app but spawn your lua script with luarun via the dialplan variable. <action application="eval" data="${luarun myscript.lua ${uuid}}"/> <action application="park"/> Then use the uuid argv[0] as the arg to a new session constructor that will hook the channel to your object and you can tell the channel to do things as long as you only execute them async session:execute("foo::bar") Remember if you are not running the session in its own thread this will block and the whole idea is sort of messy but its possible to do this.. if you script dies for instance your channel will not hangup. 3) Write your program in C where you have full access to threads etc..... (THIS IS THE BEST CHOICE IMHO) On Tue, Oct 4, 2011 at 7:46 PM, Vu Quang Hoa <vutamhoan@gmail.com> wrote:
Hi everyone, I've been trying ways to provide MOH in background of Lua script (searching and found few way) but none of them really satisfied me. I think it may implement in the same way of record_session function. So I need your advises if it is possible or not? It's a really good idea? Thank you! vutamhoan _______________________________________________ Join us at ClueCon 2011, Aug 9-11, Chicago http://www.cluecon.com 877-7-4ACLUE
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev 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@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
Thanks Anthony, I sent this message before chat with you on irc. Of cause I tried to search & search many time before asking you (I love Google) and I had already tried ESL but it still blocks any LUA session call (like session:foo()). Now I'm trying to implement MOH with async mode like record_session concept (using mod_soundtouch sample code). Hope that it will be ready within few days. -vutamhoan On Thu, Oct 6, 2011 at 10:08 PM, Anthony Minessale < anthony.minessale@gmail.com> wrote:
I believe I already answered this question when you asked on irc. But I'll answer it again so it can be logged.
To put it simply you are barking up the wrong tree trying to do asynchronous things from a lua script. Change your paradigm in your brain to think about it more like a GUI loop.
You only have 1 thread and you want to make the channel do something by itself in the background but your script is already executing....
If you want this you need 2 threads. There are several ways to get this but you have to choose one.
1) Use ESL and an external application that can be running in your own process so you can perform async operations. 2) Send the channel to the "park" app but spawn your lua script with luarun via the dialplan variable.
<action application="eval" data="${luarun myscript.lua ${uuid}}"/> <action application="park"/>
Then use the uuid argv[0] as the arg to a new session constructor that will hook the channel to your object and you can tell the channel to do things as long as you only execute them async session:execute("foo::bar") Remember if you are not running the session in its own thread this will block and the whole idea is sort of messy but its possible to do this.. if you script dies for instance your channel will not hangup.
3) Write your program in C where you have full access to threads etc..... (THIS IS THE BEST CHOICE IMHO)
On Tue, Oct 4, 2011 at 7:46 PM, Vu Quang Hoa <vutamhoan@gmail.com> wrote:
Hi everyone, I've been trying ways to provide MOH in background of Lua script (searching and found few way) but none of them really satisfied me. I think it may implement in the same way of record_session function. So I need your advises if it is possible or not? It's a really good idea? Thank you! vutamhoan _______________________________________________ Join us at ClueCon 2011, Aug 9-11, Chicago http://www.cluecon.com 877-7-4ACLUE
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev 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@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch
FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
_______________________________________________ Join us at ClueCon 2011, Aug 9-11, Chicago http://www.cluecon.com 877-7-4ACLUE
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
participants (2)
-
Anthony Minessale
-
Vu Quang Hoa