protected override async Task PublishStatusAsync(CallbackEvent callbackEvent) { const ConferenceState conferenceState = ConferenceState.Suspended; var command = new UpdateConferenceStatusCommand(SourceConference.Id, conferenceState); await CommandHandler.Handle(command); var reason = "Hearing suspended"; if (SourceParticipant == null) { SourceParticipant = SourceConference.GetJudge(); reason = "Technical assistance"; } var taskCommand = new AddTaskCommand(SourceConference.Id, SourceParticipant.Id, reason, TaskType.Hearing); await CommandHandler.Handle(taskCommand); }
public virtual async Task HandleAsync(CallbackEvent callbackEvent) { _logger.LogDebug("Handling callback"); var sw = Stopwatch.StartNew(); SourceConference = await QueryHandler.Handle <GetConferenceByIdQuery, Conference>( new GetConferenceByIdQuery(callbackEvent.ConferenceId)); if (SourceConference == null) { throw new ConferenceNotFoundException(callbackEvent.ConferenceId); } SourceParticipant = SourceConference.GetParticipants() .SingleOrDefault(x => x.Id == callbackEvent.ParticipantId); SourceEndpoint = SourceConference.GetEndpoints().SingleOrDefault(x => x.Id == callbackEvent.ParticipantId); await PublishStatusAsync(callbackEvent); _logger.LogDebug("Handled callback in {ElapsedMilliseconds}ms", sw.ElapsedMilliseconds); }
protected override async Task PublishStatusAsync(CallbackEvent callbackEvent) { var participantStatus = DeriveParticipantStatusForTransferEvent(callbackEvent); var command = new UpdateParticipantStatusAndRoomCommand(SourceConference.Id, SourceParticipant.Id, participantStatus, callbackEvent.TransferTo, callbackEvent.TransferredToRoomLabel); await CommandHandler.Handle(command); if (!callbackEvent.TransferredFromRoomLabel.ToLower().Contains("consultation") || callbackEvent.TransferTo == RoomType.HearingRoom) { return; } var roomQuery = new GetConsultationRoomByIdQuery(SourceConference.Id, callbackEvent.TransferredFromRoomLabel); var room = await QueryHandler.Handle <GetConsultationRoomByIdQuery, ConsultationRoom>(roomQuery); if (room == null) { _logger.LogError("Unable to find room {roomLabel} in conference {conferenceId}", callbackEvent.TransferredFromRoomLabel, SourceConference.Id); } else if (room.Status == RoomStatus.Live && !room.RoomParticipants.Any()) { foreach (var endpoint in room.RoomEndpoints) { await _consultationService.EndpointTransferToRoomAsync(SourceConference.Id, endpoint.EndpointId, RoomType.WaitingRoom.ToString()); } } else if (room.RoomEndpoints.Any()) { var participantsEndpoints = SourceConference.GetEndpoints().Where(x => x.DefenceAdvocate?.Equals(SourceParticipant.Username, System.StringComparison.OrdinalIgnoreCase) ?? false).Select(x => x.Id).ToList(); foreach (var endpoint in room.RoomEndpoints.Where(roomEndpoint => participantsEndpoints.Contains(roomEndpoint.EndpointId))) { await _consultationService.EndpointTransferToRoomAsync(SourceConference.Id, endpoint.EndpointId, RoomType.WaitingRoom.ToString()); } } }
protected override async Task PublishStatusAsync(CallbackEvent callbackEvent) { if (SourceParticipant == null) { return; } await ReturnRoomParticipantToWaitingRoom(); var participantState = ParticipantState.Disconnected; var updateParticipantCommand = new UpdateParticipantStatusAndRoomCommand(SourceConference.Id, SourceParticipant.Id, participantState, null, null); await CommandHandler.Handle(updateParticipantCommand); var removeFromRoomCommand = new RemoveParticipantFromParticipantRoomCommand(SourceParticipantRoom.Id, SourceParticipant.Id); await CommandHandler.Handle(removeFromRoomCommand); if (!SourceConference.IsClosed()) { await AddDisconnectedTask(); } }