Example #1
0
        /// <summary>
        /// When the IRealTimeMediaCallService detects an error and cleans up the call locally
        /// </summary>
        /// <returns></returns>
        private Task OnCallCleanup()
        {
            Log.Info(new CallerInfo(), LogContext.FrontEnd, $"[{CallId}] Received OnCallCleanup");
            if (MediaSession != null)
            {
                MediaSession.Dispose();
            }

            return(Task.CompletedTask);
        }
Example #2
0
        /// <summary>
        /// This gets called when the user hangs up the call to the bot
        /// </summary>
        /// <param name="callStateChangeNotification"></param>
        /// <returns></returns>
        private Task OnCallStateChangeNotification(CallStateChangeNotification callStateChangeNotification)
        {
            Log.Info(new CallerInfo(), LogContext.FrontEnd, $"[{CallId}] Received CallStateChangeNotification with AudioVideoCallStateType={callStateChangeNotification.CurrentState.ToString()}");

            if (callStateChangeNotification.CurrentState == CallState.Terminated)
            {
                MediaSession.Dispose();
            }
            return(Task.CompletedTask);
        }
Example #3
0
        /// <summary>
        /// When the IRealTimeMediaCallService detects an error and cleans up the call locally
        /// </summary>
        /// <returns></returns>
        private Task OnCallCleanup()
        {
            Log.Info(new CallerInfo(), LogContext.FrontEnd, $"[{CallId}] Received OnCallCleanup");
            if (MediaSession != null)
            {
                MediaSession.Dispose();
            }

            RealTimeMediaCall temp;

            ActiveMediaCalls.TryRemove(CallId, out temp);
            return(Task.CompletedTask);
        }
Example #4
0
        /// <summary>
        /// This gets called when the user hangs up the call to the bot
        /// </summary>
        /// <param name="callStateChangeNotification"></param>
        /// <returns></returns>
        private Task OnCallStateChangeNotification(CallStateChangeNotification callStateChangeNotification)
        {
            Log.Info(new CallerInfo(), LogContext.FrontEnd, $"[{CallId}] Received CallStateChangeNotification with AudioVideoCallStateType={callStateChangeNotification.CurrentState.ToString()}");

            if (callStateChangeNotification.CurrentState == CallState.Terminated)
            {
                //cleanup the media session that disposes sockets, etc
                MediaSession.Dispose();
                RealTimeMediaCall temp;
                ActiveMediaCalls.TryRemove(CallId, out temp);
            }
            return(Task.CompletedTask);
        }
Example #5
0
 private Task OnAnswerAppHostedMediaCompleted(AnswerAppHostedMediaOutcomeEvent answerAppHostedMediaOutcomeEvent)
 {
     try
     {
         Log.Info(new CallerInfo(), LogContext.FrontEnd, $"[{CallId}] OnAnswerAppHostedMediaCompleted");
         AnswerAppHostedMediaOutcome answerAppHostedMediaOutcome = answerAppHostedMediaOutcomeEvent.AnswerAppHostedMediaOutcome;
         if (answerAppHostedMediaOutcome.Outcome == Outcome.Failure)
         {
             Log.Info(new CallerInfo(), LogContext.FrontEnd, $"[{CallId}] AnswerAppHostedMedia failed with reason: {answerAppHostedMediaOutcome.FailureReason}");
             //cleanup internal resources
             MediaSession.Dispose();
         }
         else
         {
             answerAppHostedMediaOutcomeEvent.RealTimeMediaWorkflow.NotificationSubscriptions = new NotificationType[] { NotificationType.CallStateChange };
         }
         return(Task.CompletedTask);
     } catch (Exception ex)
     {
         Log.Info(new CallerInfo(), LogContext.FrontEnd, $"[{CallId}] threw {ex.ToString()}");
         throw;
     }
 }