Esempio n. 1
0
        public async Task <bool> InviteUserToOnlineMeeting(string userId, string tenantId, string callId, string accessToken)
        {
            try
            {
                var participants   = CreateParticipant();
                var requestHeaders = AuthUtil.CreateRequestHeader(accessToken);
                await _graphClient.Communications.Calls[callId].Participants.Invite(participants).Request(requestHeaders).PostAsync();

                return(true);
            }
            catch (ServiceException)
            {
                throw;
            }

            InvitationParticipantInfo[] CreateParticipant()
            {
                var participantInfo = new InvitationParticipantInfo();

                participantInfo.Identity = new IdentitySet()
                {
                    User = new Identity()
                    {
                        Id             = userId,
                        AdditionalData = new Dictionary <string, object>()
                        {
                            { "tenantId", tenantId }
                        }
                    }
                };

                return(new InvitationParticipantInfo[] { participantInfo });
            }
        }
Esempio n. 2
0
        private Call CreateGroupCallRequest(string[] userIds, string tenantId)
        {
            Call callRequest = new Call();

            callRequest.TenantId            = tenantId;
            callRequest.CallbackUri         = "https://bing.com"; // TODO: Need to update correct call back url
            callRequest.RequestedModalities = new Modality[] { Modality.Audio };
            callRequest.MediaConfig         = new ServiceHostedMediaConfig();

            callRequest.Source = new ParticipantInfo()
            {
                Identity = new IdentitySet()
                {
                    Application = new Identity()
                    {
                        Id = Environment.GetEnvironmentVariable("ClientId")
                    }
                }
            };

            var targets = new List <InvitationParticipantInfo>();

            foreach (string userId in userIds)
            {
                var participant = new InvitationParticipantInfo()
                {
                    Identity = new IdentitySet()
                    {
                        User = new Identity()
                        {
                            Id = userId
                        }
                    }
                };
                targets.Add(participant);
            }
            callRequest.Targets = targets;
            Console.WriteLine(JsonConvert.SerializeObject(callRequest));

            return(callRequest);
        }
Esempio n. 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);

            InvitationParticipantInfo callee = null;

            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;
        }