public async Task DoStepAsync(Step step, ICall call) { _call = call; if (!string.IsNullOrEmpty(call.CallState.GetBridgeId())) { await call.StopHoldingBridgeAsync().ConfigureAwait(false); } _callBridge = await call.CreateBridgeAsync(BridgeType.NoDTMF).ConfigureAwait(false); call.CallState.CalledPartyAcceptTime = DateTimeOffset.Now; call.CallState.SetBridge(_callBridge); call.InputProcessor.ChangeInputSettings(null); if (!await AreBothLinesStillConnected()) { await call.FireStateChange(Trigger.FailedCallFlow); return; } await call.AddLineToBridgeAsync(call.CallState.GetIncomingLineId(), _callBridge.Id).ConfigureAwait(false); //await call.SipBridgingApi.MuteLineAsync(call.CallState.GetIncomingLineId()); await call.AddLineToBridgeAsync(call.CallState.GetOutgoingLineId(), _callBridge.Id).ConfigureAwait(false); //await call.SipBridgingApi.MuteLineAsync(call.CallState.GetOutgoingLineId()); call.CallState.AddStepToIncomingQueue(step.GetStepFromConnector(NextStep)); await call.FireStateChange(Trigger.NextCallFlowStep); }
public void FailCaptureWhenTimeoutExpires() { if (_call.GetCurrentState() != State.CapturingInput) { return; } if (_call.CallState.InputRetryCount > _settings.MaxRetryCount && _settings.MaxRetryCount > 0) { ResetInputRetryCount(); if (_settings.Direction != Direction.Outgoing) { _call.CallState.AddStepToIncomingQueue(_settings.MaxAttemptsReachedStep); } else { _call.CallState.AddStepToOutgoingQueue(_settings.MaxAttemptsReachedStep); } } else { if (_settings.Direction != Direction.Outgoing) { _call.CallState.AddStepToIncomingQueue(_settings.NoAction); } else { _call.CallState.AddStepToOutgoingQueue(_settings.NoAction); } } _call.FireStateChange(Trigger.FailedInputCapture); }
private void InputTimeout(object sender, ElapsedEventArgs elapsedEventArgs) { _call.FireStateChange(_currentRetryCount > MaxRetries ? Trigger.FailedCallFlow : Trigger.PlayLanguagePrompts); _currentRetryCount++; DoStep(_step, _call).Start(); }
public void GoToNextStep() { var next = _step.GetStepFromConnector(NextStep); _call.Logger.Info("Outbound connected, go to next step " + next); _call.CallState.AddStepToOutgoingQueue(next); _call.FireStateChange(Trigger.NextCallFlowStep); }
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); }
public Task DoStepAsync(Step step, ICall call) { var stepSettings = step.NodeData.Properties as CheckAttemptStepSettings; if (call.CallState.AttemptCount >= stepSettings.MaxAttempts) { if (stepSettings.Direction != Direction.Outgoing) { call.CallState.AddStepToIncomingQueue(step.GetStepFromConnector(MaxAttemptsStep)); } else { call.CallState.AddStepToOutgoingQueue(step.GetStepFromConnector(MaxAttemptsStep)); } } else { call.CallState.AttemptCount++; if (stepSettings.Direction != Direction.Outgoing) { call.AddStepToProcessQueue(step.GetStepFromConnector(NextStep)); } else { call.CallState.AddStepToOutgoingQueue(step.GetStepFromConnector(NextStep)); } } call.FireStateChange(Trigger.NextCallFlowStep); return(Task.CompletedTask); }
public Task DoStepAsync(Step step, ICall call) { var stepSettings = step.NodeData.Properties as DisconnectDeviceSettings; if (stepSettings.HangUp) { switch (stepSettings.Direction) { case Direction.Incoming: call.SipLineApi.HangupLineAsync(call.CallState.GetIncomingLineId()); break; case Direction.Outgoing: call.SipLineApi.HangupLineAsync(call.CallState.GetOutgoingLineId()); break; case Direction.Both: call.SipLineApi.HangupLineAsync(call.CallState.GetIncomingLineId()); call.SipLineApi.HangupLineAsync(call.CallState.GetOutgoingLineId()); break; default: break; } } call.FireStateChange(Trigger.FinishCall); return(Task.CompletedTask); }
public async Task DoStep(Step step, ICall call) { _call = call; _call.OnWorkflowStep += OnWorkflowStep; _call.Logger.Info("Hold processor start"); _settings = (HoldStepSettings)step.NodeData.Properties; var holdingBridge = await call.CreateBridge(BridgeType.Holding); _call.CallState.SetBridge(holdingBridge); await _call.SipBridgingApi.AddLineToBridge(_call.CallState.GetIncomingLineId(), _call.CallState.GetBridgeId()); if (_settings.HoldMusic) { await _call.SipBridgingApi.PlayMusicOnHoldToBridge(_call.CallState.GetBridgeId()); } else { HoldPrompt = _settings.WaitPrompt; _call.SipApiClient.OnPromptPlaybackFinishedEvent += AriClient_OnPlaybackFinishedEvent; _currentPlaybackId = await _call.SipBridgingApi.PlayPromptToBridge(_call.CallState.GetBridgeId(), _settings.WaitPrompt, call.CallState.LanguageCode); } _call.FireStateChange(Trigger.PlaceOnHold); _call.Logger.Info("Hold processor fired"); _call.ProcessCallLogic(); }
public async Task DoStepAsync(Step step, ICall call) { _call = call; _call.OnWorkflowStep += OnWorkflowStep; _call.Logger.Information("Hold processor start {@Call}", call.CallState); _settings = (HoldStepSettings)step.NodeData.Properties; _timeoutStep = step.GetStepFromConnector("TimeoutStep"); _holdingBridge = await call.CreateBridgeAsync(BridgeType.Holding); _call.CallState.SetBridge(_holdingBridge); try { await _call.SipBridgingApi.AddLineToBridgeAsync(_call.CallState.GetIncomingLineId(), _call.CallState.GetBridgeId()); } catch (Exception e) { _call.Logger.Error(e, "Failed to place line on hold. Probably hungup. {@Call}", call.CallState); await _call.FireStateChange(Trigger.FailedCallFlow); await _call.ProcessCallLogicAsync(); return; } if (_settings.HoldMusic) { await _call.SipBridgingApi.PlayMusicOnHoldToBridgeAsync(_call.CallState.GetBridgeId()); } else { _call.CallState.HoldPrompt = _settings.WaitPrompt; _call.SipApiClient.OnPromptPlaybackFinishedAsyncEvent += AriClient_OnPlaybackFinishedAsyncEvent; _currentPlaybackId = await _call.SipBridgingApi.PlayPromptToBridgeAsync(_call.CallState.GetBridgeId(), _settings.WaitPrompt, call.CallState.LanguageCode); } call.SipApiClient.OnLineHangupAsyncEvent += SipApiClientOnOnLineHangupEvent; await _call.FireStateChange(Trigger.PlaceOnHold); _call.Logger.Information("Hold processor fired {@Call}", call.CallState); #pragma warning disable 4014 // we want to keep going without waiting. _call.ProcessCallLogicAsync(); #pragma warning restore 4014 await Task.Delay(_settings.HoldTimeoutInSeconds * 1000).ContinueWith(HoldTimeoutAction()); }
public Task DoStep(Step step, ICall call) { call.CallState.AddStepToIncomingQueue(step.GetStepFromConnector(IncomingNextStep)); call.CallState.AddStepToOutgoingQueue(step.GetStepFromConnector(OutgoingNextStep)); call.CallState.ProcessOutgoingQueue = true; call.FireStateChange(Trigger.NextCallFlowStep); return(Task.CompletedTask); }
public virtual async Task DoStepAsync(Step step, ICall call) { call.Logger.Information("Call flow begin for call {@Call}", call.CallState); call.Logger.Debug("Next step " + step.GetStepFromConnector(NextStep)); call.CallState.AddStepToIncomingQueue(step.GetStepFromConnector(NextStep)); call.CallState.TimeDeviceConnected = DateTimeOffset.Now; await call.FireStateChange(Trigger.NextCallFlowStep); }
public async Task DoStepAsync(Step step, ICall call) { var callTimer = new Timer(1000d); callTimer.Elapsed += CallTimer_Elapsed; _call = call; _step = step; _call.SipApiClient.OnLineHangupAsyncEvent += SipApiClient_OnLineHangupEvent; await _call.FireStateChange(Trigger.StartTalking); }
#pragma warning disable 1998 public async Task DoStep(ISettings settings, ICall call) #pragma warning restore 1998 { var stepSettings = (ParallelStepSettings)settings; call.CallState.AddStepToIncomingQueue(stepSettings.IncomingNextStep); call.CallState.AddStepToOutgoingQueue(stepSettings.OutgoingNextStep); call.CallState.ProcessOutgoingQueue = true; call.FireStateChange(Trigger.NextCallFlowStep); }
public Task DoStep(ISettings settings, ICall call) { call.CallState.InputRetryCount++; var inputHandlerSettings = (InputStepSettings)settings; call.FireStateChange(Trigger.CaptureInput); call.InputProcessor.ChangeInputSettings(inputHandlerSettings.GetPhoneInputHandlerSettings()); call.InputProcessor.StartUserInput(false); return(Task.CompletedTask); }
public Task DoStep(Step step, ICall call) { call.CallState.InputRetryCount++; var inputHandlerSettings = (GetInputSettings)step.NodeData.Properties; call.FireStateChange(Trigger.CaptureInput); call.InputProcessor.ChangeInputSettings(inputHandlerSettings.GetPhoneInputHandlerSettings(step)); call.InputProcessor.StartUserInput(false); return(Task.CompletedTask); }
public async Task FailCaptureWhenTimeoutExpires() { if (_call.GetCurrentState() != State.CapturingInput) { return; } if (_call.CallState.InputRetryCount > _settings.MaxRetryCount && _settings.MaxRetryCount > 0) { ResetInputRetryCount(); AddStepToProperQueue(_settings.MaxAttemptsReachedStep); } else { AddStepToProperQueue(_settings.NoAction); } await _call.FireStateChange(Trigger.FailedInputCapture); }
public async Task DoStepAsync(Step step, ICall call) { _settings = (ArkeInitSettings)step.NodeData.Properties; _call = call; try { await SetEndpointFromChannelVariable(); } catch (Exception ex) when(ex is EndpointNotFoundException) { _call.CallState.TerminationCode = TerminationCode.InvalidDeviceConfig; _call.CallState.AddStepToIncomingQueue(step.GetStepFromConnector(FailStep)); await _call.FireStateChange(SipEngine.FSM.Trigger.FailedCallFlow); return; } _call.CallState.AddStepToIncomingQueue(step.GetStepFromConnector(NextStep)); await _call.FireStateChange(SipEngine.FSM.Trigger.NextCallFlowStep); }
public async Task PlayNextPromptInQueue() { if (_asteriskCall.GetCurrentState() == State.StoppingPlayback || _promptQueue.Count == 0) { return; } _asteriskCall.Logger.Debug($"Playing next prompt in queue, queue size: {_promptQueue.Count}", _asteriskCall.LogData); try { var prompt = _promptQueue.Dequeue(); if (prompt != null) { await PlayPromptFile(prompt.PromptFile); } } catch (Exception e) { _asteriskCall.Logger.Error(e, "Error playing prompt in queue."); _asteriskCall.FireStateChange(Trigger.FinishCall); } }
public void GoToNextStep(ICall call, Step step) { if (step.NodeData.Properties.Direction != Direction.Outgoing) { call.CallState.AddStepToIncomingQueue(step.GetStepFromConnector(NextStep)); } else { call.CallState.AddStepToOutgoingQueue(step.GetStepFromConnector(NextStep)); } call.FireStateChange(Trigger.NextCallFlowStep); }
public Task DoStepAsync(Step step, ICall call) { call.Logger.Information("GetInputStep {@Call}", call.CallState); call.CallState.InputRetryCount++; call.Logger.Information("Attempt count {InputRetryCount} {@Call}", call.CallState.InputRetryCount, call.CallState); var inputHandlerSettings = (GetInputSettings)step.NodeData.Properties; call.FireStateChange(Trigger.CaptureInput); call.InputProcessor.ChangeInputSettings(inputHandlerSettings.GetPhoneInputHandlerSettings(step)); call.InputProcessor.StartUserInput(false); call.Logger.Information("Input Processor begin! {@Call}", call.CallState); return(Task.CompletedTask); }
public void GoToNextStep() { var stepSettings = _step.NodeData.Properties as StartRecordingLineSettings; if (stepSettings.Direction != Direction.Outgoing) { _call.CallState.AddStepToIncomingQueue(_step.GetStepFromConnector(NextStep)); } else { _call.CallState.AddStepToOutgoingQueue(_step.GetStepFromConnector(NextStep)); } _call.FireStateChange(Trigger.NextCallFlowStep); }
private async Task SipApiClientOnOnLineHangupEvent(ISipApiClient sender, LineHangupEvent e) { if (e.LineId != transferChannel.Id.ToString() && e.LineId != outboundLineId) { return; } if (e.LineId != transferChannel.Id.ToString()) { await _call.SipLineApi.HangupLineAsync(transferChannel.Id.ToString()); } _call.CallState.CallCanBeAbandoned = true; GoToNextStep(_call, _step); await _call.FireStateChange(Trigger.NextCallFlowStep); }
public async Task DoStep(ISettings settings, ICall call) { _promptPlayer = call.LanguageSelectionPromptPlayer; _promptPlayer.SetStepProcessor(this); _call = call; _call.Logger.Info("Get Language Step Start"); _settings = (LanguageStepSettings)settings; call.SipApiClient.OnDtmfReceivedEvent += DTMF_ReceivedEvent; call.FireStateChange(Trigger.PlayLanguagePrompts); _promptPlayer.AddPromptsToQueue(_settings.Prompts); await _promptPlayer.PlayNextPromptInQueue(); _inputTimeout.Interval = _settings.MaxDigitTimeoutInSeconds * 1000; _call.Logger.Info("Get Language Step End"); }
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); }
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); }
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); }
public async Task DoStep(ISettings settings, ICall call) { _settings = (ArkeInitStepSettings)settings; _call = call; try { await SetEndpointFromChannelVariable(); } catch (Exception ex) when(ex is EndpointNotFoundException) { _call.CallState.TerminationCode = TerminationCode.InvalidDeviceConfig; _call.CallState.AddStepToIncomingQueue(_settings.FailStep); } _call.CallState.AddStepToIncomingQueue(_settings.NextStep); _call.FireStateChange(SipEngine.FSM.Trigger.NextCallFlowStep); }
public async Task DoStepAsync(Step step, ICall call) { _promptPlayer = call.LanguageSelectionPromptPlayer; _promptPlayer.SetStepProcessor(this); _call = call; _call.Logger.Information("Get Language Step Start {@Call}", call.CallState); _step = step; _settings = (LanguageStepSettings)step.NodeData.Properties; call.SipApiClient.OnDtmfReceivedEvent += DTMF_ReceivedEvent; await call.FireStateChange(Trigger.PlayLanguagePrompts); _promptPlayer.AddPromptsToQueue(_settings.Prompts); await _promptPlayer.PlayNextPromptInQueue(); _inputTimeout.Interval = _settings.MaxDigitTimeoutInSeconds * 1000; _call.Logger.Information("Get Language Step End {@Call}", call.CallState); }
public async Task DoStepAsync(Step step, ICall call) { call.Logger.Information("GetInputStep {@Call}", call.CallState); call.CallState.InputRetryCount++; call.Logger.Information("Attempt count {InputRetryCount} {@Call}", call.CallState.InputRetryCount, call.CallState); var inputHandlerSettings = (GetInputSettings)step.NodeData.Properties; await call.FireStateChange(Trigger.CaptureInput); call.InputProcessor.ChangeInputSettings(inputHandlerSettings.GetPhoneInputHandlerSettings(step)); call.InputProcessor.StartUserInput(false); if (!string.IsNullOrEmpty(call.InputProcessor.DigitsReceived)) { await call.InputProcessor.ProcessDigitsReceived(); } call.Logger.Information("Input Processor begin! {@Call}", call.CallState); }
public async Task AriClient_OnRecordingFinishedEvent(ISipApiClient sender, RecordingFinishedEventHandlerArgs args) { await _call.FireStateChange(Trigger.NextCallFlowStep); }