voiplync-2013ucmadtmf

Using ToneController to get more than one digit


I am new to UCMA and I read Tone Controller example in UCMA sdk 4.0. I know this is the way you can record tone played by user:

void toneController_ToneReceived(object sender, ToneControllerEventArgs e)
    {
        Console.WriteLine("Tone Received: " + (ToneId)e.Tone + " (" + e.Tone + ")");
        if ((ToneId)e.Tone == ToneId.Tone0)
        {
            _waitForToneReceivedEventCompleted.Set();
        }
        else
        {
            ToneController tc = (ToneController)sender;
            tc.Send(e.Tone);
        }
    }

I want to know if there is a way to find the series of tones received from user not just one ( for example 10 digit), I want to use it for direct dialing.


Solution

  • You can simply do it in a loop:

    string tone_received = "";
    int number_of_tone_received = 0;
    while(number_of_tone_received++ < 10)
            {
                //Sync; wait for ToneReceivedEvent
                _waitForToneReceivedEventCompleted.WaitOne();
                _waitForToneReceivedEventCompleted.Reset();
            }
            _waitForToneReceivedEventCompleted.WaitOne();
    
    
     void toneController_ToneReceived(object sender, ToneControllerEventArgs e)
        {
            tone_received =  tone_received + e.Tone;
            _waitForToneReceivedEventCompleted.Set();
    
        }