Example #1
0
        private Task OnIncomingCallReceived(RealTimeMediaIncomingCallEvent incomingCallEvent)
        {
            Log.Info(new CallerInfo(), LogContext.FrontEnd, $"[{CallId}] OnIncomingCallReceived");

            //handles the media for this call like creating sockets, registering for events on the socket and sending/receiving media
            MediaSession = new MediaSession(CallId, CorrelationId, this);
            incomingCallEvent.RealTimeMediaWorkflow.Actions = new ActionBase[]
            {
                new AnswerAppHostedMedia
                {
                    MediaConfiguration = MediaSession.MediaConfiguration,
                    OperationId        = Guid.NewGuid().ToString()
                }
            };

            //subscribe for roster changes and call state changes
            incomingCallEvent.RealTimeMediaWorkflow.NotificationSubscriptions = new NotificationType[] { NotificationType.RosterUpdate, NotificationType.CallStateChange };
            ThreadId = incomingCallEvent.IncomingCall.ThreadId;

            Log.Info(new CallerInfo(), LogContext.FrontEnd, $"[{CallId}] Answering the call");

            ActiveMediaCalls.AddOrUpdate(CallId, this, (callId, oldcall) => this);

            return(Task.CompletedTask);
        }
        /// <summary>
        /// Invokes handler for incoming call
        /// </summary>
        /// <param name="conversation">Conversation corresponding to the incoming call</param>
        /// <returns>WorkFlow to be executed for the call</returns>
        internal async Task <RealTimeMediaWorkflow> HandleIncomingCall(Conversation conversation)
        {
            Trace.TraceInformation($"RealTimeMediaCallService [{CallLegId}]: Received incoming call");
            var incomingCall = new RealTimeMediaIncomingCallEvent(conversation, CreateInitialWorkflow());
            var eventHandler = OnIncomingCallReceived;

            if (eventHandler != null)
            {
                await eventHandler.Invoke(incomingCall).ConfigureAwait(false);
            }
            else
            {
                Trace.TraceInformation($"RealTimeMediaCallService [{CallLegId}]: No handler specified for incoming call");
                return(null);
            }

            return(incomingCall.RealTimeMediaWorkflow);
        }
Example #3
0
        private Task OnIncomingCallReceived(RealTimeMediaIncomingCallEvent incomingCallEvent)
        {
            Log.Info(new CallerInfo(), LogContext.FrontEnd, $"[{CallId}] OnIncomingCallReceived");

            MediaSession = new MediaSession(CallId, CorrelationId);
            incomingCallEvent.RealTimeMediaWorkflow.Actions = new ActionBase[]
            {
                new AnswerAppHostedMedia
                {
                    MediaConfiguration = MediaSession.MediaConfiguration,
                    OperationId        = Guid.NewGuid().ToString()
                }
            };

            incomingCallEvent.RealTimeMediaWorkflow.NotificationSubscriptions = new NotificationType[] { NotificationType.CallStateChange };

            Log.Info(new CallerInfo(), LogContext.FrontEnd, $"[{CallId}] Answering the call");

            return(Task.CompletedTask);
        }