You do realize that you don't even need Lua to accomplish what you want to do, right? Instead of launching "luarun callback.lua ${caller_id_number}" as your API you can just do an originate:<br><br><span style="font-family: courier new,monospace;"><action application="set" data="api_hangup_hook=originate </span><span style="font-family: courier new,monospace;">{ignore_early_media=true} </span><span style="font-family: courier new,monospace;">sofia/gateway/</span><div style="font-family: courier new,monospace;" class="im">
voipms/1${caller_id_number} 12345 XML default"/><br></div><br>Create an extension 12345 (or pick a different number) and have the dialplan apps in that extension do all the stuff you are trying to do. Example:<br>
<br><span style="font-family: courier new,monospace;"><extension name="callback_stuff"></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> <condition field="destination_number" expression="^(12345)$"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <action application="sleep" data="500"/></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> <action application="set" inline="true" data="message_dir=/usr/local/freeswitch/sounds/en/us/callie/custom/callback/"/></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <!-- Now do whatever you were going to do</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> By the looks of your script you want the caller to enter some digits<br>
Then you probably wanted to transfer the caller to that destination<br> You can use play-and-get-digits for this<br> Please see the wiki because I can't do any more work on this right now-<br>
my 3 year old son just jumped on my lap and is making me break his two<br> Pop Tarts into little pieces and he wants to type and eat...<br style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> --></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </condition></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></extension></span><br><br>Remember the golden rule: Use the dialplan wherever possible because it will always be more efficient than a scripting language. (BTW, when the FS book comes out you'll see more about this topic.)<br>
<br>HTH and happy dialing!<br>-MC<br><br><div class="gmail_quote">2010/6/10 Aloysius Lloyd <span dir="ltr"><<a href="mailto:lloyd.aloysius@sunteltech.ca">lloyd.aloysius@sunteltech.ca</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Thanks Vitalli.<br><br>Increase the short delay solve the problem. I increase from 1000 to 2000.<br><br><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(80, 0, 80);"></span>But when I answer the phone there is a silent before play the file because of the dealy. <br>
<br>How to improve this? Is there any setting to make the session fast.<div><div></div><div class="h5"><br><br>Thanks<br>Lloyd<br>
<br><br><div class="gmail_quote">2010/6/10 Vitalii Colosov <span dir="ltr"><<a href="mailto:vetali100@gmail.com" target="_blank">vetali100@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Try to add short delay - session:sleep:<div><font color="#500050" face="arial, sans-serif"><span style="border-collapse: collapse;"><br></span></font></div><div><font color="#500050" face="arial, sans-serif"><span style="border-collapse: collapse;">...</span></font></div>
<div>session:setAutoHangup(false);</div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(80, 0, 80);"><br></span></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(80, 0, 80);">session:sleep(1000);</span></div>
<div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(80, 0, 80);">...</span></div><div><div><br></div><div>Sometimes I was getting session is not ready, and fixed this by adding short delay.</div>
<div><br></div><div>Maybe you have same problem here.</div><div><br></div><div>Regards,</div><div>Vitalie</div><div><br></div><div><br><br><div class="gmail_quote">10 ΙΐΞΡ 2010 Η. 16:20 ΠΟΜΨΪΟΧΑΤΕΜΨ Aloysius Lloyd <span dir="ltr"><<a href="mailto:lloyd.aloysius@sunteltech.ca" target="_blank">lloyd.aloysius@sunteltech.ca</a>></span> ΞΑΠΙΣΑΜ:<div>
<div></div><div><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">VItalli,<br><br>I try your suggestion. Now the script look like this<div><br><br>os.execute("sleep " .. tonumber(10));<br>
<br>pin_number_test="0511";<br>out_gateway1="sofia/gateway/voipms/1";<br>message_dir="/usr/local/freeswitch/sounds/en/us/callie/custom/callback/";<br>
<br>number_to_call= argv[1];<br><br></div>session = freeswitch.Session("{ignore_early_media=true,originate_timeout=40}"..out_gateway1..number_to_call);<br>session:setAutoHangup(false);<br><div><br>if ( session:ready() ) then<br>
session:sleep(1000);<br> if (session:answered()) then<br> session:sleep(1000);<br> session:streamFile(message_dir.."enter-dest.wav");<br> end<br>end<br><br>
</div>
===<br>
<br>Also I try 5 test . This time out of 5 test, wave file play only one time. Other for 4 tests silent.<br><br>Thanks<br>Lloyd<br><br>
<br><br><div class="gmail_quote">2010/6/10 Vitalii Colosov <span dir="ltr"><<a href="mailto:vetali100@gmail.com" target="_blank">vetali100@gmail.com</a>></span><div><div></div><div><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
It looks OK what you wrote - we have almost same lua code.<div><br><div>The only thing that I have in addition in my script is "if (session:answered())" construction.</div><div><br></div><div>Try to write it like this:</div>
<div>...</div><div><br></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">if ( session:ready() ) then<br> session:sleep(1000); </span></div>
<div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;"> if (session:answered()) then</span></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;"> session:sleep(1000); </span></div>
<div>
<div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;"> session:streamFile(message_dir.."enter-dest.wav");</span></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;"> end</span></div>
</div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;"><br>end</span></div><div><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">...</span></div>
<div><br></div><div>Not sure why this should work and that does not, but this is how it works for me - worth trying at lest.</div><div><br></div><div><br></div><div>Regards,</div><div>Vitalie</div><div><br><br><div class="gmail_quote">
10 ΙΐΞΡ 2010 Η. 9:07 ΠΟΜΨΪΟΧΑΤΕΜΨ Aloysius Lloyd <span dir="ltr"><<a href="mailto:lloyd.aloysius@sunteltech.ca" target="_blank">lloyd.aloysius@sunteltech.ca</a>></span> ΞΑΠΙΣΑΜ:<div><div></div><div><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br clear="all">without bypass_media_after_bridge=true same results.<br><br>Lloyd<br><br>
<br><br><div class="gmail_quote">2010/6/10 Aloysius Lloyd <span dir="ltr"><<a href="mailto:lloyd.aloysius@sunteltech.ca" target="_blank">lloyd.aloysius@sunteltech.ca</a>></span><div><div></div><div><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I try the bypass_media_after_bridge=true .. same results.<br><br>Thanks<br><font color="#888888">Lloyd</font><div><div></div><div><br><br>
<br><br><div class="gmail_quote">On Thu, Jun 10, 2010 at 2:00 AM, Sergey Scheglov <span dir="ltr"><<a href="mailto:sid@eltc.ru" target="_blank">sid@eltc.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
χ Thu, 10 Jun 2010 01:26:51 -0400<br>
<div>Aloysius Lloyd <<a href="mailto:lloyd.aloysius@gmail.com" target="_blank">lloyd.aloysius@gmail.com</a>> wrote:<br>
<br>
<br>
</div><div>> session =<br>
> freeswitch.Session("{bypass_media_after_bridge=true,ignore_early_media=true,originate_timeout=40}"..out_gateway1..number_to_call);<br>
> session:setAutoHangup(false);<br>
><br>
</div>> Thanks<br>
> Lloyd<br>
<br>
Try without bypass_media_after_bridge=true<br>
<br>
Regard<br>
Sergey Scheglov<br>
<br>
_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</blockquote></div><br>
</div></div></blockquote></div></div></div><br>
<br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div></div></div><br></div></div>
<br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div></div></div><br>
<br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div></div></div><br></div></div>
<br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br>
</div></div><br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br>