Exemplo n.º 1
0
        public async Task <Unit> Handle(InitializeEquipmentRequest request, CancellationToken cancellationToken)
        {
            var connection = new EquipmentConnection(request.ConnectionId, request.Name, request.Devices,
                                                     ImmutableDictionary <ProducerSource, UseMediaStateInfo> .Empty);

            await _repository.SetConnection(request.Participant, connection);

            var isJoined = await _mediator.Send(new CheckIsParticipantJoinedRequest(request.Participant));

            if (!isJoined)
            {
                await _repository.RemoveConnection(request.Participant, connection.ConnectionId);

                throw EquipmentError.ParticipantNotJoined.ToException();
            }

            await _mediator.Send(new UpdateSynchronizedObjectRequest(request.Participant.ConferenceId,
                                                                     SynchronizedEquipment.SyncObjId(request.Participant.Id)));

            return(Unit.Value);
        }
Exemplo n.º 2
0
        public async Task <Unit> Handle(UpdateStatusRequest request, CancellationToken cancellationToken)
        {
            var(participant, connectionId, status) = request;

            var connection = await _repository.GetConnection(participant, connectionId);

            if (connection == null)
            {
                throw EquipmentError.NotInitialized.ToException();
            }

            var updatedConnection = connection with {
                Status = status
            };
            await _repository.SetConnection(participant, updatedConnection);

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

            return(Unit.Value);
        }
    }