示例#1
0
 public void StartUserInput(bool reset)
 {
     if (reset)
     {
         DigitsReceived = "";
     }
     SetTimerInterval();
     if (MaxDigitTimeoutInSeconds > 0)
     {
         DigitTimeoutTimer.Start();
     }
 }
示例#2
0
 public void StartUserInput(bool reset)
 {
     if (reset)
     {
         DigitsReceived = "";
     }
     _call.CallState.InputRetryCount++;
     SetTimerInterval();
     if (MaxDigitTimeoutInSeconds > 0)
     {
         DigitTimeoutTimer.Start();
     }
 }
示例#3
0
        public void AriClient_OnChannelDtmfReceivedEvent(ISipApiClient sipApiClient, DtmfReceivedEvent dtmfReceivedEvent)
        {
            DigitTimeoutTimer.Stop();
            _call.Logger.Debug($"OnChannel Dtmf Received Event {dtmfReceivedEvent.LineId}");
            if (_call.GetCurrentState() == State.LanguagePrompts)
            {
                return;
            }
            if (dtmfReceivedEvent.LineId != _call.CallState.GetIncomingLineId())
            {
                return;
            }

            LogDtmfValue(dtmfReceivedEvent);

            CaptureDigitIfInValidState(dtmfReceivedEvent);

            if (_call.GetCurrentState() == State.PlayingInterruptiblePrompt)
            {
                _promptPlayer.StopPrompt();
            }

            ProcessDigitsReceived();
        }
示例#4
0
        public async void AriClient_OnChannelDtmfReceivedEvent(ISipApiClient sipApiClient, DtmfReceivedEvent dtmfReceivedEvent)
        {
            DigitTimeoutTimer.Stop();
            if (_call.GetCurrentState() == State.LanguagePrompts)
            {
                return;
            }
            if (!ShouldProcessDigit(dtmfReceivedEvent))
            {
                return;
            }
            _call.Logger.Debug($"OnChannel Dtmf Received Event {dtmfReceivedEvent.LineId}");

            LogDtmfValue(dtmfReceivedEvent);

            CaptureDigitIfInValidState(dtmfReceivedEvent);

            if (_call.GetCurrentState() == State.PlayingInterruptiblePrompt)
            {
                await _promptPlayer.StopPromptAsync();
            }

            await ProcessDigitsReceived();
        }
示例#5
0
        public void ProcessDigitsReceived()
        {
            if (_call.GetCurrentState() != State.CapturingInput ||
                DigitsReceived.Length < NumberOfDigitsToWaitForNextStep)
            {
                DigitTimeoutTimer.Start();
                return;
            }

            if (NumberOfDigitsToWaitForNextStep == 0 &&
                !DigitsReceived.EndsWith(TerminationDigit))
            {
                DigitTimeoutTimer.Start();
                return;
            }

            if (TerminationDigit != "")
            {
                if (DigitsReceived.EndsWith(TerminationDigit))
                {
                    if (_settings.SetValueAsDestination)
                    {
                        _call.CallState.Destination = DigitsReceived.Substring(0, DigitsReceived.Length - 1);
                    }

                    _call.CallState.AddStepToIncomingQueue(_settings.NextStep);
                    _call.CallState.InputData = DigitsReceived.Substring(0, DigitsReceived.Length - 1);
                    ResetInputRetryCount();
                    _call.FireStateChange(Trigger.InputReceived);
                    return;
                }
            }
            else if (_settings.SetValueAsDestination)
            {
                _call.CallState.Destination = DigitsReceived.Substring(0, DigitsReceived.Length);
                _call.CallState.AddStepToIncomingQueue(_settings.NextStep);
                _call.CallState.InputData = DigitsReceived.Substring(0, DigitsReceived.Length);
                ResetInputRetryCount();
                _call.FireStateChange(Trigger.InputReceived);
                return;
            }
            if (NumberOfDigitsToWaitForNextStep == 0)
            {
                DigitTimeoutTimer.Start();
                return;
            }

            var validStep = false;

            foreach (var option in _settings.Options.Where(option => option.Input == DigitsReceived))
            {
                ResetInputRetryCount();
                _call.CallState.AddStepToIncomingQueue(option.NextStep);
                validStep = true;
            }

            if (!validStep)
            {
                if (_call.CallState.InputRetryCount > _settings.MaxRetryCount && _settings.MaxRetryCount > 0)
                {
                    ResetInputRetryCount();
                    _call.AddStepToProcessQueue(_settings.MaxAttemptsReachedStep);
                }
                else
                {
                    _call.CallState.AddStepToIncomingQueue(_settings.Invalid);
                }
            }
            _call.FireStateChange(Trigger.InputReceived);
        }
示例#6
0
        public async Task ProcessDigitsReceived()
        {
            if (DigitsReceived.Length < NumberOfDigitsToWaitForNextStep)
            {
                DigitTimeoutTimer.Start();
                return;
            }

            if (NumberOfDigitsToWaitForNextStep == 0 &&
                !DigitsReceived.EndsWith(TerminationDigit))
            {
                DigitTimeoutTimer.Start();
                return;
            }

            if (TerminationDigit != "")
            {
                if (DigitsReceived.EndsWith(TerminationDigit))
                {
                    if (_settings.SetValueAsDestination)
                    {
                        _call.CallState.Destination = DigitsReceived.Substring(0, DigitsReceived.Length - 1);
                    }
                    else if (!string.IsNullOrEmpty(_settings.SetValueAs))
                    {
                        DynamicState.SetProperty(_call.CallState, _settings.SetValueAs, DigitsReceived);
                    }

                    AddStepToProperQueue(_settings.NextStep);
                    _call.CallState.InputData = DigitsReceived.Substring(0, DigitsReceived.Length - 1);
                    ResetInputRetryCount();
                    await _call.FireStateChange(Trigger.InputReceived);

                    return;
                }
            }
            else if (_settings.SetValueAsDestination)
            {
                _call.CallState.Destination = DigitsReceived.Substring(0, DigitsReceived.Length);
                AddStepToProperQueue(_settings.NextStep);
                _call.CallState.InputData = DigitsReceived.Substring(0, DigitsReceived.Length);
                ResetInputRetryCount();
                await _call.FireStateChange(Trigger.InputReceived);

                return;
            }
            else if (!string.IsNullOrEmpty(_settings.SetValueAs))
            {
                DynamicState.SetProperty(_call.CallState, _settings.SetValueAs, DigitsReceived);
                _call.CallState.InputData = DigitsReceived;
                ResetInputRetryCount();
                AddStepToProperQueue(_settings.NextStep);
                await _call.FireStateChange(Trigger.InputReceived);

                return;
            }

            if (NumberOfDigitsToWaitForNextStep == 0)
            {
                DigitTimeoutTimer.Start();
                return;
            }

            var validStep = false;

            foreach (var option in _settings.Options.Where(option => option.Key == DigitsReceived.Substring(0, NumberOfDigitsToWaitForNextStep)))
            {
                ResetInputRetryCount();

                AddStepToProperQueue(option.Value);

                validStep = true;
            }

            if (!validStep)
            {
                if (_call.CallState.InputRetryCount > _settings.MaxRetryCount && _settings.MaxRetryCount > 0)
                {
                    ResetInputRetryCount();

                    AddStepToProperQueue(_settings.MaxAttemptsReachedStep);
                }
                else
                {
                    AddStepToProperQueue(_settings.Invalid);
                }
            }
            await _call.FireStateChange(Trigger.InputReceived);
        }