[Freeswitch-users] A DTMF issue

Steven Ayre steveayre at gmail.com
Tue Jun 7 19:56:31 MSD 2011


- checks whether the session is still active (true anytime between call
starts and hangup)
- also session:ready will return false if the call is being
transferred. *Bottom line is you should always be checking
session:ready on any loops and
periodicly throughout your script and exit asap if it returns false.*

[http://wiki.freeswitch.org/wiki/Mod_lua#session:ready]



On 7 June 2011 16:54, Steven Ayre <steveayre at gmail.com> wrote:

> It's a simple fix. Always check session.ready when you loop. Yes, that's
> how it's designed to work.
>
> -Steve
>
>
>
> On 7 June 2011 16:05, Yungwei Chen <yungwei at resolvity.com> wrote:
>
>> That's how it's supposed to work and no workaround?
>>
>>
>>
>> *From:* freeswitch-users-bounces at lists.freeswitch.org [mailto:
>> freeswitch-users-bounces at lists.freeswitch.org] *On Behalf Of *Steven Ayre
>> *Sent:* Friday, June 03, 2011 5:46 PM
>> *To:* FreeSWITCH Users Help
>> *Subject:* Re: [Freeswitch-users] A DTMF issue
>>
>>
>>
>> You should be checking session.ready() in that loop, as it is I think
>> you'll find the scripts are never ending when the channel is hung up.
>>
>> streamFile/flushDigits probably return instantly, but then get called
>> again on the next loop iteration. The problem would get slightly worse after
>> each test call since there would be an extra copy of the script running.
>>
>> Try replacing:
>>     while(true) {
>> with:
>>     while(session.ready()) {
>>
>> -Steve
>>
>> On 3 June 2011 23:35, Yungwei Chen wrote:
>>
>> Hi,
>>
>> When testing the following javascript program, I notice a problem that it
>> takes longer and longer for freeswitch to respond to DTMF input for some
>> reason.
>> Please refer to http://pastebin.freeswitch.org/16435 for debug logs.
>> Notice that the difference in time between any adjacent pairs of the
>> following is increasing as time goes by. Am I missing something here?
>>        switch_ivr_play_say.c:1279 Codec Activated L16 at 8000hz 1 channels
>> 20ms
>>        switch_rtp.c:3302 RTP RECV DTMF 2:960
>> Thanks.
>>
>> Here's the javascript program:
>> var dtmf_digits = "";
>>
>>
>> function on_dtmf_28(session, type, digits, arg)
>> {
>>    if (type == "dtmf")
>>    {
>>
>>        dtmf_digits = digits.digit;
>>
>>        console_log("dtmf_digits=" + dtmf_digits + "\n");
>>
>>        return false; // barge-in / done
>>    }
>>    return true;
>> }
>>
>> while (true)
>> {
>>        dtmf_digits = "";
>>        session.flushDigits();
>>        session.streamFile("/usr/local/freeswitch/sounds/long-prompt.wav",
>> on_dtmf_28, false);
>>
>>        if(dtmf_digits.length == 0)
>>        {
>>            /* no input */
>>            console_log("no input\n");
>>            session.speak('flite', 'kal', 'no input!', null);
>>        }
>>        else if(dtmf_digits == "1" || dtmf_digits == "2")
>>        {
>>                console_log("match "+dtmf_digits+"\n");
>>                session.speak('flite', 'kal', 'you pressed ' + dtmf_digits+
>> '!', null);
>>        }
>>        else
>>        {
>>            /* no match */
>>            console_log("no match\n");
>>            session.speak('flite', 'kal', "no match!", null);
>>        }
>>
>> }
>>
>>
>>
>> _______________________________________________
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110607/c686a178/attachment.html 


More information about the FreeSWITCH-users mailing list