Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        private void HandleToneReceived(object sender, ToneReceivedEventArgs args)
        {
            switch (args.Tone)
            {
            case Rtc.Internal.Platform.ResourceContract.ToneValue.Tone1:
            {
                m_toneReceived.TrySetResult("sip:[email protected]");
                break;
            }

            case Rtc.Internal.Platform.ResourceContract.ToneValue.Tone2:
            {
                m_toneReceived.TrySetResult("sip:[email protected]");
                break;
            }

            case Rtc.Internal.Platform.ResourceContract.ToneValue.Tone3:
            {
                m_toneReceived.TrySetResult("sip:[email protected]");
                break;
            }

            case Rtc.Internal.Platform.ResourceContract.ToneValue.Tone4:
            {
                m_toneReceived.TrySetResult("sip:[email protected]");
                break;
            }

            default:
            {
                break;
            }
            }
        }
Exemplo n.º 3
0
        private async Task HandleToneEventAsync(IAudioVideoFlow flow, ToneReceivedEventArgs e)
        {
            string tone = ToneValueToString(e.Tone);

            if (tone == null)
            {
                Logger.Instance.Warning("[AudioVideoIVRJob] Tone could not be identified : {0}.", e.Tone.ToString());
                return;
            }

            Logger.Instance.Information("[AudioVideoIVRJob] ToneReceivedEvent received : {0}.", tone);

            if (currentMenu?.KeyMap == null || !currentMenu.KeyMap.ContainsKey(tone))
            {
                Logger.Instance.Information("[AudioVideoIVRJob] No action defined for this tone.");
                return;
            }

            var keyAction = currentMenu.KeyMap[tone];

            if (keyAction.Action == AudioVideoIVRActions.PlayPrompt)
            {
                Logger.Instance.Information("[AudioVideoIVRJob] Playing prompt.");
                currentMenu = keyAction;
                await PlayPromptAsync(flow).ConfigureAwait(false);
            }
            else if (keyAction.Action == AudioVideoIVRActions.RepeatPrompt)
            {
                Logger.Instance.Information("[AudioVideoIVRJob] Repeating prompt.");
                await PlayPromptAsync(flow).ConfigureAwait(false);
            }
            else if (keyAction.Action == AudioVideoIVRActions.GoToPreviousPrompt)
            {
                Logger.Instance.Information("[AudioVideoIVRJob] Going to previous prompt.");
                currentMenu = currentMenu.ParentInput ?? currentMenu;
                await PlayPromptAsync(flow).ConfigureAwait(false);
            }
            else if (keyAction.Action == AudioVideoIVRActions.TransferToUser)
            {
                Logger.Instance.Information("[AudioVideoIVRJob] Transferring the call to {0}.", keyAction.User);
                currentMenu = keyAction;
                await PlayPromptAsync(flow).ConfigureAwait(false);

                var audioVideoCall = flow.Parent as IAudioVideoCall;

                await audioVideoCall.TransferAsync(keyAction.User, null, loggingContext).ConfigureAwait(false);

                CleanupEventHandlers(flow);
            }
            else if (keyAction.Action == AudioVideoIVRActions.TerminateCall)
            {
                Logger.Instance.Information("[AudioVideoIVRJob] Terminating the call.");
                var audioVideoCall = flow.Parent as IAudioVideoCall;

                await audioVideoCall.TerminateAsync(loggingContext).ConfigureAwait(false);

                CleanupEventHandlers(flow);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Method to be invoked when user presses a key on the dial pad.
 /// </summary>
 /// <param name="sender"><see cref="AudioVideoFlow"/> which received the event.</param>
 /// <param name="e"><see cref="ToneReceivedEventArgs"/> containing information about the event.</param>
 private void ToneReceivedEvent(object sender, ToneReceivedEventArgs e)
 {
     HandleToneEventAsync(sender as IAudioVideoFlow, e).ContinueWith(t =>
     {
         if (t.IsFaulted)
         {
             Logger.Instance.Warning("[AudioVideoIVRJob] Exception while processing tone received event.", t.Exception);
         }
         else
         {
             Logger.Instance.Information("[AudioVideoIVRJob] ToneReceivedEvent processed.");
         }
     });
 }