コード例 #1
0
        public async Task Handle(ParticipantLeftNotification notification, CancellationToken cancellationToken)
        {
            var(participant, _) = notification;

            var previousRoom = await _roomRepository.UnsetParticipantRoom(participant);

            await _mediator.Send(
                new UpdateSynchronizedObjectRequest(participant.ConferenceId, SynchronizedRooms.SyncObjId));

            await _mediator.Publish(new ParticipantsRoomChangedNotification(participant.ConferenceId,
                                                                            new Dictionary <Participant, ParticipantRoomChangeInfo>
            {
                { participant, ParticipantRoomChangeInfo.Left(previousRoom) }
            }));
        }
コード例 #2
0
        public async Task Handle(ConferenceClosedNotification notification, CancellationToken cancellationToken)
        {
            var conferenceId = notification.ConferenceId;

            // we can not use the other UseCases here as they implement custom logic to keep the participants in the room system,
            // here we especially want to kick all participants from all rooms

            // concurrency: as we delete all participants and all rooms at once, all future SetParticipantRoomUseCases will fail,
            // as no rooms exist any more, so it is impossible that new mappings will be created

            var result = await _roomRepository.DeleteAllRoomsAndMappingsOfConference(conferenceId);

            await _mediator.Send(
                new UpdateSynchronizedObjectRequest(notification.ConferenceId, SynchronizedRooms.SyncObjId));

            await _mediator.Publish(new RoomsRemovedNotification(conferenceId, result.DeletedRooms));

            await _mediator.Publish(new ParticipantsRoomChangedNotification(conferenceId,
                                                                            result.DeletedMapping.ToDictionary(pair => new Participant(conferenceId, pair.Key),
                                                                                                               pair => ParticipantRoomChangeInfo.Left(pair.Value))));
        }