Exemple #1
0
        /// <summary>
        /// Incoming call handler.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="CollectionEventArgs{TEntity}"/> instance containing the event data.</param>
        private void CallsOnIncoming(ICallCollection sender, CollectionEventArgs <ICall> args)
        {
            var call = args.AddedResources.First();

            var callee   = call.Resource.Targets.First();
            var callType = callee?.Identity?.GetApplicationInstance() == null ? IncidentCallType.BotIncoming : IncidentCallType.BotEndpointIncoming;

            var incidentCallContext = new IncidentCallContext(callType, Guid.Empty.ToString());

            AddCallToHandlers(call, incidentCallContext);

            var mediaToPrefetch = new List <MediaInfo>();

            foreach (var m in MediaMap)
            {
                mediaToPrefetch.Add(m.Value.MediaInfo);
            }

            var answerTask = call.AnswerAsync(
                mediaToPrefetch,
                new[] { Modality.Audio });

            Task.Run(async() =>
            {
                try
                {
                    await answerTask.ConfigureAwait(false);
                    graphLogger.Info("Started answering incoming call");
                }
                catch (Exception ex)
                {
                    graphLogger.Error(ex, "Exception happened when answering the call.");
                }
            });
        }
Exemple #2
0
        /// <summary>
        /// Add call to call handlers.
        /// </summary>
        /// <param name="call">The call to be added.</param>
        /// <param name="incidentCallContext">The incident call context.</param>
        private void AddCallToHandlers(ICall call, IncidentCallContext incidentCallContext)
        {
            Validator.NotNull(incidentCallContext, nameof(incidentCallContext));

            var statusData = this.IncidentStatusManager.GetIncident(incidentCallContext.IncidentId);

            CallHandler callHandler;
            InvitationParticipantInfo callee;

            switch (incidentCallContext.CallType)
            {
            case IncidentCallType.BotMeeting:
                // Call to meeting.
                callHandler = new MeetingCallHandler(this, call, statusData);
                break;

            case IncidentCallType.ResponderNotification:
                // call to an user.
                callee      = call.Resource.Targets.First();
                callHandler = new ResponderCallHandler(this, call, callee.Identity.User.Id, statusData);
                break;

            default:
                throw new NotSupportedException($"Invalid call type in incident call context: {incidentCallContext.CallType}");
            }

            this.CallHandlers[call.Id] = callHandler;
        }
Exemple #3
0
        /// <summary>
        /// Add call to call handlers.
        /// </summary>
        /// <param name="call">The call to be added.</param>
        /// <param name="incidentCallContext">The incident call context.</param>
        private void AddCallToHandlers(ICall call, IncidentCallContext incidentCallContext)
        {
            Validator.NotNull(incidentCallContext, nameof(incidentCallContext));

            var callHandler = default(CallHandler);

            var statusData = this.IncidentStatusManager.GetIncident(incidentCallContext.IncidentId);

            var callee = default(ParticipantInfo);

            switch (incidentCallContext.CallType)
            {
            case IncidentCallType.BotMeeting:
                // Call to meeting.
                callHandler = new MeetingCallHandler(this, call, statusData);
                break;

            case IncidentCallType.ResponderNotification:
                // call to an user.
                callee      = call.Resource.Targets.First();
                callHandler = new ResponderCallHandler(this, call, callee.Identity.User.Id, statusData);
                break;

            case IncidentCallType.BotIncoming:
                // call from an user.
                callHandler = new IncomingCallHandler(this, call, null /* The app endpoint ID */);
                break;

            case IncidentCallType.BotEndpointIncoming:
                // call from an user to an bot endpoint.
                callee      = call.Resource.Targets.First();
                callHandler = new IncomingCallHandler(this, call, callee.Identity.GetApplicationInstance().Id);
                break;

            default:
                throw new NotSupportedException($"Invalid call type in incident call context: {incidentCallContext.CallType}");
            }

            this.CallHandlers[call.Id] = callHandler;
        }