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