Beispiel #1
0
 private void SipApiClient_OnLineHangupEvent(SipEngine.Api.ISipApiClient sender, SipEngine.Events.LineHangupEvent e)
 {
     if (e.LineId == _call.CallState.GetIncomingLineId() ||
         e.LineId == _call.CallState.GetOutgoingLineId())
     {
         _call.SipApiClient.OnLineHangupEvent -= SipApiClient_OnLineHangupEvent;
         _call.AddStepToProcessQueue(_step.LinkedSteps.Single(s => s.FromPort == "NextIncomingStep").To);
         _call.AddStepToProcessQueue(_step.LinkedSteps.Single(s => s.FromPort == "NextOutgoingStep").To);
     }
 }
        public Task DoStep(Step step, ICall call)
        {
            var stepSettings = step.NodeData.Properties as CheckAttemptStepSettings;

            if (call.CallState.AttemptCount >= stepSettings.MaxAttempts)
            {
                call.AddStepToProcessQueue(step.GetStepFromConnector(MaxAttemptsStep));
            }
            else
            {
                call.CallState.AttemptCount++;
                call.AddStepToProcessQueue(step.GetStepFromConnector(NextStep));
            }
            call.FireStateChange(Trigger.NextCallFlowStep);
            return(Task.CompletedTask);
        }
Beispiel #3
0
        public Task DoStep(ISettings settings, ICall call)
        {
            var stepSettings = settings as PlayValueStepSettings;

            if (stepSettings == null)
            {
                throw new ArgumentException("PlayValueStepProcessor called with invalid Step settings");
            }
            var numbersToPromptsConverter = new MoneyValueToPrompts();
            var valueToPlay = (decimal?)call.CallState.GetType().GetProperty(stepSettings.Value)?.GetValue(call.CallState);

            if (valueToPlay == null)
            {
                throw new ArgumentException("Value specified does not exist on CallState: " + stepSettings.Value);
            }

            var prompts = numbersToPromptsConverter.GetPromptsForValue(valueToPlay.Value);

            var promptSettings = new PlayerPromptSettings()
            {
                IsInterruptible = stepSettings.IsInterruptible,
                NextStep        = stepSettings.NextStep,
                Prompts         = prompts
            };

            call.PromptPlayer.DoStep(promptSettings);
            call.AddStepToProcessQueue(stepSettings.NextStep);
            return(Task.CompletedTask);
        }
        public Task DoStep(ISettings settings, ICall call)
        {
            var stepSettings = settings as CheckAttemptStepSettings;

            if (call.CallState.AttemptCount >= stepSettings.MaxAttempts)
            {
                call.AddStepToProcessQueue(stepSettings.MaxAttemptsStep);
            }
            else
            {
                call.CallState.AttemptCount++;
                call.AddStepToProcessQueue(stepSettings.NextStep);
            }
            call.FireStateChange(Trigger.NextCallFlowStep);
            return(Task.CompletedTask);
        }
Beispiel #5
0
 public void GoToNextStep()
 {
     _promptPlayer.HaltPromptPlayback();
     CleanupEventHooks();
     _call.AddStepToProcessQueue(_step.GetStepFromConnector(NextStep));
     _call.FireStateChange(Trigger.NextCallFlowStep);
 }
Beispiel #6
0
        public void FailCaptureWhenTimeoutExpires()
        {
            if (_call.GetCurrentState() != State.CapturingInput)
            {
                return;
            }

            if (_call.CallState.InputRetryCount > _settings.MaxRetryCount && _settings.MaxRetryCount > 0)
            {
                ResetInputRetryCount();
                _call.AddStepToProcessQueue(_settings.MaxAttemptsReachedStep);
            }
            else
            {
                _call.CallState.AddStepToIncomingQueue(_settings.NoAction);
            }
            _call.FireStateChange(Trigger.FailedInputCapture);
        }
Beispiel #7
0
 private void HoldTimeoutCallBack()
 {
     // we somehow got stuck in the holding bridge. Lets move on.
     // we're not on hold anymore, so we can just remove our events and continue
     _call.Logger.Warning("On Hold Timeout for call {@Call}", _call.CallState);
     _call.SipApiClient.OnPromptPlaybackFinishedAsyncEvent -= AriClient_OnPlaybackFinishedAsyncEvent;
     _call.OnWorkflowStep -= OnWorkflowStep;
     _call.SipApiClient.OnLineHangupAsyncEvent -= SipApiClientOnOnLineHangupEvent;
     _call.AddStepToProcessQueue(_timeoutStep);
     _call.FireStateChange(Trigger.NextCallFlowStep);
 }
Beispiel #8
0
        public async Task CallOutbound(string dialString)
        {
            _call.Logger.Info("Outbound start " + dialString);
            try
            {
                _call.CallState.CreateOutgoingLine(
                    await _call.SipLineApi.CreateOutboundCall(dialString, (_step.NodeData.Properties as CallOutboundSettings)?.OutboundEndpointName).ConfigureAwait(false));
                var outgoingLineId   = _call.CallState.GetOutgoingLineId();
                var currentCallState = await _call.SipLineApi.GetLineState(outgoingLineId).ConfigureAwait(false);

                var noAnswerTimeout = new Stopwatch();
                noAnswerTimeout.Start();
                while (currentCallState != "Up")
                {
                    if (noAnswerTimeout.Elapsed.TotalSeconds > 90)
                    {
                        _call.AddStepToProcessQueue(_step.GetStepFromConnector(NoAnswer));
                        _call.FireStateChange(Trigger.NextCallFlowStep);
                        return;
                    }
                    await Task.Delay(100).ConfigureAwait(false);

                    currentCallState = await _call.SipLineApi.GetLineState(outgoingLineId).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                _call.Logger.Error(ex, "Outbound call can't get through ");
                _call.AddStepToProcessQueue(_step.GetStepFromConnector(FailedStep));
                _call.FireStateChange(Trigger.NextCallFlowStep);
                return;
            }
            await _call.SipLineApi.AnswerLine(_call.CallState.GetOutgoingLineId()).ConfigureAwait(false);

            GoToNextStep();
        }
Beispiel #9
0
        public async Task DoStep(ISettings settings, ICall call)
        {
            await call.StopHoldingBridge();

            _callBridge = await call.CreateBridge(BridgeType.NoDTMF);

            call.CallState.SetBridge(_callBridge);

            await call.AddLineToBridge(call.CallState.GetIncomingLineId(), _callBridge.Id);

            await call.AddLineToBridge(call.CallState.GetOutgoingLineId(), _callBridge.Id);

            var stepSettings = (BridgeCallStepSettings)settings;

            call.AddStepToProcessQueue(stepSettings.NextStep);
            call.FireStateChange(Trigger.NextCallFlowStep);
        }
Beispiel #10
0
        public async Task DoStep(Step step, ICall call)
        {
            if (!string.IsNullOrEmpty(call.CallState.GetBridgeId()))
            {
                await call.StopHoldingBridge().ConfigureAwait(false);
            }
            _callBridge = await call.CreateBridge(BridgeType.NoDTMF).ConfigureAwait(false);

            call.CallState.SetBridge(_callBridge);

            await call.AddLineToBridge(call.CallState.GetIncomingLineId(), _callBridge.Id).ConfigureAwait(false);

            await call.AddLineToBridge(call.CallState.GetOutgoingLineId(), _callBridge.Id).ConfigureAwait(false);

            call.AddStepToProcessQueue(step.GetStepFromConnector(NextStep));
            call.FireStateChange(Trigger.NextCallFlowStep);
        }
Beispiel #11
0
        public async Task CallOutbound(string dialingId)
        {
            _call.Logger.Info("Outbound start " + dialingId);
            _call.CallState.CreateOutgoingLine(
                await _call.SipLineApi.CreateOutboundCall(dialingId));
            try
            {
                var outgoingLineId   = _call.CallState.GetOutgoingLineId();
                var currentCallState = await _call.SipLineApi.GetLineState(outgoingLineId);

                while (currentCallState != "Up")
                {
                    await Task.Delay(100);

                    currentCallState = await _call.SipLineApi.GetLineState(outgoingLineId);
                }
            }
            catch (Exception ex)
            {
                _call.Logger.Error(ex, "Outbound call can't get through ");
                _call.AddStepToProcessQueue(_settings.FailedStep);
                _call.FireStateChange(Trigger.NextCallFlowStep);
                return;
            }

            var bridge = await _call.CreateBridge(BridgeType.WithDTMF);

            await _call.SipBridgingApi.AddLineToBridge(
                _call.CallState.GetIncomingLineId(), bridge.Id);

            await _call.SipBridgingApi.AddLineToBridge(
                _call.CallState.GetOutgoingLineId(), bridge.Id);

            GoToNextStep();
            _call.Logger.Info("Outbound end, go to next step " + dialingId);
        }
Beispiel #12
0
 public void GoToNextStep()
 {
     _call.AddStepToProcessQueue(_settings.NextStep);
     _call.FireStateChange(Trigger.NextCallFlowStep);
 }