[Freeswitch-users] How to set up a DTMF callback in C or C#?

Kris kris at livecall.com
Sat Feb 12 02:23:37 MSK 2011


        protected string DtmfReceived(Char Digit, TimeSpan 
DurationMilliseconds) //t is the duration of the 
tone -TimeSpan.FromMilliseconds(dtmf.duration));
        {
            SaveDigit(Digit.ToString());
            BaseLog.WriteLine(BaseLogLevel.Info, CallID, sv_uuid, 
CurrentAction, Termination.Reason, "DtmfReceived {0} Duration:{1}", 
Digit.ToString(), DurationMilliseconds.ToString());
            //
            if (Termination.TerminatorDigits.IndexOf(Digit) >= 0 || 
Termination.TerminatorDigits.IndexOf('@') >= 0) //@ means any digit
                return "break";  //returning anything breaks play
            if (Termination.MaximumDigits > 0) //break the play
                return "break";  //returning anything but 
SWITCH_STATUS_SUCCESS breaks play
            return String.Empty;// play continues
        }
        void SetDTMFFunction(bool set)
        {
            if (Session != null && Session.Ready())
            {
                if (set)
                    Session.DtmfReceivedFunction = DtmfReceived;// 
public Func<Char, TimeSpan, string>
                else
                    Session.DtmfReceivedFunction = null;
            }
        }

----- Original Message ----- 
From: "Frankie Yiu" <yky1628 at yahoo.com>
To: <freeswitch-users at lists.freeswitch.org>
Sent: Friday, February 11, 2011 12:13 PM
Subject: [Freeswitch-users] How to set up a DTMF callback in C or C#?


Hi there,

If I want to set up a DTMF callBack to a function (in either C or C#) when a
caller presses a key, what function should I use to set it up?

Thanks,
Frankie






More information about the FreeSWITCH-users mailing list