public async Task <Unit> Handle(TalkingStickReturnRequest request, CancellationToken cancellationToken) { var participant = request.Participant; var rooms = await _mediator.FetchSynchronizedObject <SynchronizedRooms>(participant.ConferenceId, SynchronizedRooms.SyncObjId); if (!rooms.Participants.TryGetValue(participant.Id, out var roomId)) { throw SceneError.RoomNotFound.ToException(); } await using (await _repository.LockRoom(participant.ConferenceId, roomId)) { var currentSpeaker = await _repository.GetCurrentSpeaker(participant.ConferenceId, roomId); if (currentSpeaker != null && currentSpeaker.Value.Equals(participant)) { await _repository.RemoveCurrentSpeaker(currentSpeaker.Value.ConferenceId, roomId); await _modeHandler.InvalidateTalkingSceneWithLockAcquired(currentSpeaker.Value.ConferenceId, roomId); } else { return(Unit.Value); } } await _mediator.Send(new UpdateSynchronizedObjectRequest(participant.ConferenceId, SynchronizedSceneTalkingStick.SyncObjId(roomId))); return(Unit.Value); }
public async Task Handle(RoomsRemovedNotification notification, CancellationToken cancellationToken) { var(conferenceId, removedRoomIds) = notification; foreach (var removedRoomId in removedRoomIds) { await _repository.RemoveCurrentSpeaker(conferenceId, removedRoomId); await _repository.ClearQueue(conferenceId, removedRoomId); } }
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); }