Esempio n. 1
0
        /// <summary>
        /// This updates the VMRs for a conference when a participant joins or leaves a VMR
        /// </summary>
        /// <param name="conference"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        private async Task UpdateConferenceRoomParticipants(Conference conference, ConferenceEventRequest request)
        {
            if (!request.IsParticipantAndVmrEvent())
            {
                return;
            }

            var roomId        = long.Parse(request.ParticipantRoomId);
            var participantId = Guid.Parse(request.ParticipantId);


            switch (request.EventType)
            {
            case EventType.Joined:
                conference.AddParticipantToRoom(roomId, participantId);
                break;

            case EventType.Disconnected:
                await _consultationResponseTracker.ClearResponses(conference, participantId);

                conference.RemoveParticipantFromRoom(roomId, participantId);
                break;

            default: return;
            }

            await _conferenceCache.UpdateConferenceAsync(conference);
        }
Esempio n. 2
0
        public async Task NotifyConsultationResponseAsync(Conference conference, string roomLabel, Guid requestedForId,
                                                          ConsultationAnswer answer)
        {
            var endpoint = conference.Endpoints.FirstOrDefault(e => e.Id == requestedForId);

            if (endpoint != null)
            {
                await PublishResponseMessage(conference, roomLabel, endpoint.Id, answer);

                return;
            }

            var participantFor = conference.Participants.First(x => x.Id == requestedForId);
            await _consultationResponseTracker.UpdateConsultationResponse(conference, participantFor.Id, answer);

            var haveAllAccepted =
                await _consultationResponseTracker.HaveAllParticipantsAccepted(conference, participantFor.Id);

            if (answer == ConsultationAnswer.Accepted && !haveAllAccepted)
            {
                return;
            }

            await PublishResponseMessage(conference, roomLabel, participantFor.Id, answer);

            if (participantFor.LinkedParticipants.Any())
            {
                await NotifyLinkedParticipantsOfConsultationResponseAsync(conference, participantFor, roomLabel, answer);
            }

            if (answer == ConsultationAnswer.Transferring && participantFor.LinkedParticipants.Any())
            {
                await _consultationResponseTracker.ClearResponses(conference, requestedForId);
            }
        }