private async Task PlayPromptAsync(IAudioVideoFlow flow, AudioVideoIVRAction action) { string wavFile = promptMap.GetOrNull(action); Logger.Instance.Information("[AudioVideoIVRJob] playing prompt: {0}.", wavFile); var resourceUri = new Uri(string.Format("{0}://{1}/resources/{2}", m_callbackUri.Scheme, m_callbackUri.Host, wavFile)); try { await flow.PlayPromptAsync(resourceUri, m_loggingContext).ConfigureAwait(false); } catch (CapabilityNotAvailableException ex) { Logger.Instance.Error("[AudioVideoIVRJob] PlayPrompt api is not available!", ex); } catch (RemotePlatformServiceException ex) { ErrorInformation error = ex.ErrorInformation; if (error != null && error.Code == ErrorCode.Informational && error.Subcode == ErrorSubcode.CallTerminated) { Logger.Instance.Information("[AudioVideoIVRJob] Call terminated while playing prompt."); } else { throw; } } }
private async Task HandleToneEventAsync(IAudioVideoFlow avFlow, ToneReceivedEventArgs e) { AudioVideoIVRAction action = (AudioVideoIVRAction)e.Tone; Logger.Instance.Information("[AudioVideoIVRJob] ToneReceivedEvent received : {0}.", action); if (!promptMap.ContainsKey(action)) { Logger.Instance.Information("[AudioVideoIVRJob] No action defined for this tone."); return; } if (action == AudioVideoIVRAction.TerminateCall) { Logger.Instance.Information("[AudioVideoIVRJob] Terminating the call."); var avCall = avFlow.Parent as IAudioVideoCall; await avCall.TerminateAsync(m_loggingContext).ConfigureAwait(false); CleanupEventHandlers(avFlow); } else { await PlayPromptAsync(avFlow, action).ConfigureAwait(false); } }