示例#1
0
        private static IEnumerable <IScene> GetAvailableScenes(string roomId, SynchronizedRooms rooms,
                                                               IReadOnlyList <IScene> scenes)
        {
            var presenterScenes = scenes.OfType <PresenterScene>();

            return(presenterScenes.Where(x =>
                                         rooms.Participants.TryGetValue(x.PresenterParticipantId, out var presenterRoomId) &&
                                         presenterRoomId == roomId));
        }
示例#2
0
        public void GetParticipantsOfRoom_EmptyParticipants_ReturnEmpty()
        {
            // arrange
            var rooms = new SynchronizedRooms(ImmutableList <Room> .Empty, "d",
                                              ImmutableDictionary <string, string> .Empty);

            // act
            var result = SceneUtilities.GetParticipantsOfRoom(rooms, "test");

            // assert
            Assert.Empty(result);
        }
示例#3
0
        public void ParticipantsOfRoomChanged_PreviousValueNull_ReturnTrue()
        {
            // arrange
            var current = new SynchronizedRooms(ImmutableList <Room> .Empty, "default",
                                                ImmutableDictionary <string, string> .Empty);
            SynchronizedRooms?previous = null;

            // act
            var result = SceneUtilities.ParticipantsOfRoomChanged("room1", current, previous);

            // assert
            Assert.True(result);
        }
示例#4
0
        public static bool ParticipantsOfRoomChanged(string roomId, SynchronizedRooms rooms,
                                                     SynchronizedRooms?previousRooms)
        {
            if (previousRooms == null)
            {
                return(true);
            }

            var roomsParticipants         = GetParticipantsOfRoom(rooms, roomId);
            var previousRoomsParticipants = GetParticipantsOfRoom(previousRooms, roomId);

            return(!roomsParticipants.SequenceEqual(previousRoomsParticipants));
        }
示例#5
0
        public void ParticipantsOfRoomChanged_SomeChangesInOtherRooms_ReturnFalse()
        {
            // arrange
            var current = new SynchronizedRooms(ImmutableList <Room> .Empty, "default",
                                                ImmutableDictionary <string, string> .Empty);
            var previous = new SynchronizedRooms(ImmutableList <Room> .Empty, "default",
                                                 new Dictionary <string, string> {
                { "p1", "room2" }
            });

            // act
            var result = SceneUtilities.ParticipantsOfRoomChanged("room1", current, previous);

            // assert
            Assert.False(result);
        }
示例#6
0
        private async ValueTask <Participant?> VerifyCurrentSpeakerInRoom(Participant?currentSpeaker, string roomId,
                                                                          SynchronizedRooms rooms)
        {
            if (currentSpeaker == null)
            {
                return(null);
            }

            if (CheckParticipantIsInRoom(currentSpeaker.Value, roomId, rooms))
            {
                return(currentSpeaker);
            }

            await _repository.RemoveCurrentSpeaker(currentSpeaker.Value.ConferenceId, roomId);

            return(null);
        }
示例#7
0
        public void GetParticipantsOfRoom_SomeParticipants_ReturnParticipants()
        {
            // arrange
            var rooms = new SynchronizedRooms(ImmutableList <Room> .Empty, "d", new Dictionary <string, string>
            {
                { "p1", "room1" },
                { "p2", "room1" },
                { "p3", "room2" },
                { "p4", "room4" },
            });

            // act
            var result = SceneUtilities.GetParticipantsOfRoom(rooms, "room1");

            // assert
            AssertHelper.AssertScrambledEquals(new[] { "p1", "p2" }, result);
        }
示例#8
0
 private static bool CheckParticipantIsInRoom(Participant participant, string roomId, SynchronizedRooms rooms)
 {
     return(rooms.Participants.TryGetValue(participant.Id, out var actualRoomId) && actualRoomId == roomId);
 }
示例#9
0
        private async ValueTask ElectNewCurrentSpeaker(string conferenceId, string roomId, SynchronizedRooms rooms,
                                                       TalkingStickMode mode)
        {
            if (mode == TalkingStickMode.Queue)
            {
                var nextSpeaker = await _repository.Dequeue(conferenceId, roomId);

                if (nextSpeaker == null)
                {
                    return;
                }

                if (!CheckParticipantIsInRoom(nextSpeaker.Value, roomId, rooms))
                {
                    await ElectNewCurrentSpeaker(conferenceId, roomId, rooms, mode);

                    return;
                }

                await _repository.SetCurrentSpeakerAndRemoveFromQueue(nextSpeaker.Value, roomId);
            }
        }
示例#10
0
 private IEnumerable <Room> MapOpenedRooms(SynchronizedRooms syncRooms, IEnumerable <string> openedRooms)
 {
     return(syncRooms.Rooms.Where(x => openedRooms.Contains(x.RoomId)).ToList());
 }
示例#11
0
 public static IEnumerable <string> GetParticipantsOfRoom(SynchronizedRooms rooms, string roomId)
 {
     return(rooms.Participants.Where(x => x.Value == roomId).Select(x => x.Key));
 }