Exemplo n.º 1
0
        void ipClient_DTMFToneRecognized(object sender, DTMFToneEventArgs e)
        {
            bool inAudio = e.DTMFType == DTMFType.InAudio ? true : false;

            // Check to make sure this DTMF event isn't some sort of an echo.
            if (IsDTMFEcho(e))
            {
                return;
            }

            AddDTMFEvent(e);

            RaiseDTMFToneRecognized(new CallInputEventArgs(e.LineNumber, e.DTMFString, inAudio));
        }
Exemplo n.º 2
0
        private void AddDTMFEvent(DTMFToneEventArgs e)
        {
            try
            {
                // Update our DTMF event data for this line
                DTMFEventData newDTMFData = new DTMFEventData();
                newDTMFData.DTMFString = e.DTMFString;
                newDTMFData.InAudio    = e.DTMFType == DTMFType.InAudio ? true : false;
                newDTMFData.Time       = DateTime.Now;

                dtmfEvents[e.LineNumber].Add(newDTMFData);

                // Only hold a maximum of the last 10 digits
                if (dtmfEvents[e.LineNumber].Count > 10)
                {
                    dtmfEvents[e.LineNumber].RemoveAt(0);
                }
            }
            catch
            {
            }
        }
Exemplo n.º 3
0
        private bool IsDTMFEcho(DTMFToneEventArgs e)
        {
            try
            {
                bool inAudio = e.DTMFType == DTMFType.InAudio ? true : false;

                foreach (DTMFEventData dtmfData in dtmfEvents[e.LineNumber])
                {
                    // Are the digits the same?
                    if (dtmfData.DTMFString == e.DTMFString)
                    {
                        // Is it a different type of dtmf event?
                        if (dtmfData.InAudio != inAudio)
                        {
                            // Is the timestamp difference within 3 seconds?
                            if (((TimeSpan)(DateTime.Now - dtmfData.Time)).TotalSeconds <= 3)
                            {
                                // If we get here, this is probably an echo
                                return(true);
                            }
                        }
                        else
                        {
                            // Is the timestamp differnce within 50 ms?
                            if (((TimeSpan)(DateTime.Now - dtmfData.Time)).TotalMilliseconds <= 50)
                            {
                                // If we get here, this is probably an echo
                                return(true);
                            }
                        }
                    }
                }
            }
            catch
            {
            }

            return(false);
        }
        private bool IsDTMFEcho(DTMFToneEventArgs e)
        {
            try
            {
                bool inAudio = e.DTMFType == DTMFType.InAudio ? true : false;

                foreach (DTMFEventData dtmfData in dtmfEvents[e.LineNumber])
                {
                    // Are the digits the same?
                    if (dtmfData.DTMFString == e.DTMFString)
                    {
                        // Is it a different type of dtmf event?
                        if (dtmfData.InAudio != inAudio)
                        {
                            // Is the timestamp difference within 3 seconds?
                            if (((TimeSpan)(DateTime.Now - dtmfData.Time)).TotalSeconds <= 3)
                            {
                                // If we get here, this is probably an echo
                                return true;
                            }
                        }
                        else
                        {
                            // Is the timestamp differnce within 50 ms?
                            if (((TimeSpan)(DateTime.Now - dtmfData.Time)).TotalMilliseconds <= 50)
                            {
                                // If we get here, this is probably an echo
                                return true;
                            }
                        }
                    }
                }
            }
            catch
            {
            }

            return false;
        }
        void ipClient_DTMFToneRecognized(object sender, DTMFToneEventArgs e)
        {
            bool inAudio = e.DTMFType == DTMFType.InAudio ? true : false;

            // Check to make sure this DTMF event isn't some sort of an echo.
            if (IsDTMFEcho(e))
                return;

            AddDTMFEvent(e);

            RaiseDTMFToneRecognized(new CallInputEventArgs(e.LineNumber, e.DTMFString, inAudio));
        }
        private void AddDTMFEvent(DTMFToneEventArgs e)
        {
            try
            {
                // Update our DTMF event data for this line
                DTMFEventData newDTMFData = new DTMFEventData();
                newDTMFData.DTMFString = e.DTMFString;
                newDTMFData.InAudio = e.DTMFType == DTMFType.InAudio ? true : false;
                newDTMFData.Time = DateTime.Now;

                dtmfEvents[e.LineNumber].Add(newDTMFData);

                // Only hold a maximum of the last 10 digits
                if (dtmfEvents[e.LineNumber].Count > 10)
                    dtmfEvents[e.LineNumber].RemoveAt(0);
            }
            catch
            {
            }
        }