<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:courier,monaco,monospace,sans-serif;font-size:12pt">The notion of the callback goes all the way down to the core. The C portion of the code is where the digit is dequeued so there is no way to avoid it.<br><br>So, When you call streamFile you can not only pass a function to callback, you can also pass an arbitrary object. That way you can get that object as "arg" in your example callback and push the digits onto a shared string there.<br><br><br>The intention is to make a pure js class for this kind of thing that we can put in tree and people can use it to make their scripts.<br><br><br><br><pre>function mycb (type, data, arg) {<br><br>        if (type == "dtmf") {<br>                arg.digits += data;<br>                return false;<br>        }<br>}</pre><br>var dtmf = new Object();<br>dtmf.digits = "";<br>session.streamFile("blah.wav", mycb, dtmf);<br>//say you need 3 digits
so subtract how many you have so far.<br>dtmf.digits += getDigits(3 - dtmf.digits.length, "#", 5000);<br><br>This is a crude example but you can see how you could write this into a permanently used module everyone could use. The idea is to make the js the place where you can continue to code functionality without touching the core. That is the reason the default api is the lowest level possible without going too far.<br><br>This pure js module has yet to be written but we probably should get started on it soon before we make everyone duplicate this kind of thing....<br><br><br><div>Anthony Minessale II<br><br><span>FreeSWITCH <a target="_blank" href="http://www.freeswitch.org/">http://www.freeswitch.org/</a></span><br><span>ClueCon <a target="_blank" href="http://www.cluecon.com/">http://www.cluecon.com/</a></span><br><br>AIM: anthm<br>MSN:anthony_minessale@hotmail.com<br>JABBER:anthony.minessale@gmail.com<br>IRC: irc.freenode.net
#freeswitch</div><div><br>FreeSWITCH Developer Conference<br>sip:888@conference.freeswitch.org<br>iax:guest@conference.freeswitch.org/888<br>googletalk:conf+888@conference.freeswitch.org<br>pstn:213-799-1400</div><div style="font-family: courier,monaco,monospace,sans-serif; font-size: 12pt;"><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Jonas Gauffin <jonas.gauffin@gmail.com><br>To: freeswitch-users@lists.freeswitch.org<br>Sent: Saturday, August 11, 2007 3:37:26 AM<br>Subject: Re: [Freeswitch-users] Javascript input<br><br><div>Ok. Let's take an example:<br><br>I got a voicemail application that plays a lot of phrases. Let's check<br>a simple example:<br><br>session.streamFile("you_have.wav");<br>session.streamFile("2.wav");<br>session.streamFile("new_messages.wav");<br>choice = session.getDigit(1, "", 5000);<br><br>Ok. I want to skip to the second voicemail by
pressing 2. That's not<br>possible with the code above. Instead you have to do something like<br>this:<br><br>var _digits = "";<br>function on_dtmf(type, digits, arg)<br>{<br> _digits += digits;<br> return false;<br>}<br><br>function say(phrase)<br>{<br> if (_digits != "")<br> return false;<br> session.streamFile(phrase, on_dtmf);<br>}<br><br>function getDigits(length, terminators, timeout)<br>{<br> if (_digits != '')<br> {<br> var tempVar = _digits;<br> _digits = "";<br> return tempVar;<br> }<br> return session.getDigits(length, terminators, timeout);<br>}<br><br>say("you_have.wav");<br>say("2.wav");<br>say("new_messages");<br>choice = getDigits(1, "", 5000);<br><br>Right? That will abort speach on input and return the pressed digit.<br>But what if we want to enter a pincode
or something like that? Then we<br>need to handle both _digits AND use session.getDigits:<br><br>function getDigits(length, terminators, timeout)<br>{<br> if (_digits.length < length)<br> {<br> tempVar = _digits;<br> _digits = "";<br> tempVar += session.getDigits(length - _digits.length, terminators, timeout);<br> return tempVar;<br> }<br> else<br> {<br> tempVar = _digits;<br> _digits = "";<br> return tempVar;<br> }<br>}<br><br>Get my point? All of that could have been two lines of code if there<br>was an alternative to streamFile which do not remove the DTMF from the<br>input queue (or whatever it's called):<br><br>session.streamAndAbortOnDtmf("theFile.wav");<br>var digit = session.getDigits(1, "", 3000);<br><br>All I wanted
was an alternative that is simple. Again: I'm not looking<br>for a replacement of streamFile but an complement for those who just<br>want to do the above.<br><br>I apologize if my examples are incorrect in some way, I've written<br>them directly in this email with my mind as a reference. I might have<br>done some syntax errors or something like that. Afterall, it's<br>saturday =)<br><br>But anyway. I can create an alternative to streamFile which does<br>On 8/10/07, Chris Danielson <chris@maxpowersoft.com> wrote:<br>> Jonas,<br>> To what purpose would having a streamFile abort without DTMF input? If<br>> the streamFile operation is going to require aborting then DTMF input or<br>> voice recognition will be the means. Jonas, your heart is in the right<br>> place, but everything you have asked for is already implemented in a very<br>> flexible manner within the JavaScript engine.<br>> Regards,<br>> Chris
Danielson<br>><br>> > Yes. The current architecture works just fine.<br>> ><br>> > I'm not saying that the current method should be removed. It's<br>> > excellent in those cases when you want to filter input during<br>> > streamFile and recordFile. But I still think that those cases are more<br>> > rare than wanting to abort the speech.<br>> ><br>> > Consider this a feature request then: A new streamFile that do not eat<br>> > DTMF but aborts the speech instead. Or simply a new argument that<br>> > specifies that the method should abort instead of eating the DTMF.<br>> ><br>> > On 8/10/07, Mike Murdock <mmurdock@coppercom.com> wrote:<br>> >> You do currently have the option to either continue playing the prompt<br>> >> or abort the prompt. In order to collect the digits during the playing<br>> >> of a prompt you must code a dtmf_callback handler.
When a user presses a<br>> >> digit your call back handler gets called. You can decide it the digit is<br>> >> a valid one and if it is valid return "false" (or the digit) causing the<br>> >> prompt to stop. If the digit is not valid you can ignore it by returning<br>> >> "true" and the prompting will continue. While this does require the<br>> >> application developer to code a digit handler it gives you a much richer<br>> >> option for the handling of the results.<br>> >><br>> >> You are free to develop your own wrapper function to force the<br>> >> particular behaviour you want. I have written a getdigits function in<br>> >> javascript that you are welcome to use to get the behaviour you are<br>> >> looking for.<br>> >><br>> >><br>> >> Michael B. Murdock<br>> >><br>> >><br>> >><br>> >>
________________________________<br>> >><br>> >> From: freeswitch-users-bounces@lists.freeswitch.org on behalf of Jonas<br>> >> Gauffin<br>> >> Sent: Fri 8/10/2007 2:49 AM<br>> >> To: freeswitch-users@lists.freeswitch.org<br>> >> Subject: Re: [Freeswitch-users] Javascript input<br>> >><br>> >><br>> >><br>> >> Why not simply make another streamFile method that aborts on input.<br>> >> Then the user can choose which one he wants.<br>> >><br>> >> I can elaborate my wish too. I guess that you have used a lot of IVR<br>> >> applications, right?<br>> >> For instance, you call your phone provider and they have a IVR m<br>><br>><br>> _______________________________________________<br>> Freeswitch-users mailing list<br>> Freeswitch-users@lists.freeswitch.org<br>> <a target="_blank"
href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>> UNSUBSCRIBE:<a target="_blank" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>> <a target="_blank" href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>><br><br>_______________________________________________<br>Freeswitch-users mailing list<br>Freeswitch-users@lists.freeswitch.org<br><a target="_blank" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>UNSUBSCRIBE:<a target="_blank" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br><a target="_blank"
href="http://www.freeswitch.org">http://www.freeswitch.org</a><br></div></div><br></div></div><br>
<hr size=1>Take the Internet to Go: Yahoo!Go puts the <a href="http://us.rd.yahoo.com/evt=48253/*http://mobile.yahoo.com/go?refer=1GNXIC">Internet in your pocket:</a> mail, news, photos & more. </body></html>