<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-AU" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Seven Du,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Thanks for your response. I eventually found a way by sending via the Event Socket Layer:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">sendmsg <channel uuid><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">call-command: execute<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">execute-app-name: break<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></a></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Then sending the CUSTOM message and using the con:pop(1,5000) approach to pop the CUSTOM message of the event queue.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">This approach solves the problem, although I wish I could send an event via ESL that will trigger the setInputCallback(…) function.
However I have not found a way to do that as yet.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Andrew<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org]
<b>On Behalf Of </b>Seven Du<br>
<b>Sent:</b> Tuesday, 9 December 2014 10:16 AM<br>
<b>To:</b> FreeSWITCH Users Help<br>
<b>Subject:</b> Re: [Freeswitch-users] Re - FreeSWITCH Lua CUSTOM events interrupting session:streamFile playback - is this possible?<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">I believe the playback_terminitors chan var works, or you could try set an input callback and return “break” when dtmf detected.
<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">-- <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Seven Du<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt"><a href="http://about.me/dujinfang">http://about.me/dujinfang</a></span><o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><a href="http://www.dujinfang.com">http://www.dujinfang.com</a><o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt"><a href="http://www.freeswitch.org.cn">http://www.freeswitch.org.cn</a></span><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Sent with <a href="http://www.sparrowmailapp.com/?sig">Sparrow</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p><span style="color:#A0A0A8">On Tuesday, December 9, 2014 at 7:00 AM, Andrew Keil wrote:<o:p></o:p></span></p>
<blockquote style="border:none;border-left:solid windowtext 1.0pt;padding:0cm 0cm 0cm 8.0pt;margin-left:0cm;margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<div>
<p style="margin:0cm;margin-bottom:.0001pt">To FreeSWITCH users,<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> <o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt">After progressing with Lua inside FreeSWITCH I have a question that I cannot source an answer for within the current FreeSWITCH documentation.<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> <o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt">I have a requirement for an external application to process an event (via the event socket layer) then return the results back to the application while an audio file is played back in a loop to the caller.<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> <o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt">From the current documentation this method allows for the event to be sent then the return event is “consumed” using a polling approach. However the caller is listening to silence.<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> <o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt">function poll()<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> -- create event and listener<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> local event = freeswitch.Event("CUSTOM", "ping::running?")<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> local con = freeswitch.EventConsumer("CUSTOM", "ping::running!")<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> <o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> -- add text ad libitum<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> event:addHeader("hi", "there")<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> -- fire event<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> event:fire()<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> -- and wait for reply but not very long<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> local retevent = con:pop(1, 5000)<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> if retevent then<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> print("reply received")<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> freeswitch.consoleLog("DEBUG", string.format("reply received: %s\n",retevent:getHeader("Result")))<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> return true<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> end<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> print("no reply")<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> freeswitch.consoleLog("DEBUG", "no reply\n")
<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> return false<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt">end<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> <o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"><u>Some questions:</u><o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt">Is there a way to playback audio (eg. session:streamFile(…)) while this takes place, since currently session:streamFile(…) seems to be a blocking function (ie. Finishes when the audio file is played back completely)?<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt">Is there a way to use <span lang="EN">
session:setInputCallback(…) to handle an external CUSTOM event being returned (since this would then be able to interrupt the session:streamFile(…) just like it does for DTMF or speech recognition)?</span><o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"><span lang="EN"> </span><o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"><span lang="EN">If you have a preferred approach to solving this then I am open to your suggestions.</span><o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> <o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt">I appreciate any assistance that you can give.<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> <o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt">Kind Regards,<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> <o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt">Andrew Keil<o:p></o:p></p>
<p style="margin:0cm;margin-bottom:.0001pt"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">_________________________________________________________________________<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Professional FreeSWITCH Consulting Services: <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Official FreeSWITCH Sites<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://www.freeswitch.org">http://www.freeswitch.org</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://confluence.freeswitch.org">http://confluence.freeswitch.org</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://www.cluecon.com">http://www.cluecon.com</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">FreeSWITCH-users mailing list<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://www.freeswitch.org">http://www.freeswitch.org</a><o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>