Exemple #1
0
        public async Task <Unit> Handle(SendEquipmentCommandRequest request, CancellationToken cancellationToken)
        {
            var connection = await _repository.GetConnection(request.Participant, request.ConnectionId);

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

            await _mediator.Publish(
                new SendEquipmentCommandNotification(request.Participant, request.ConnectionId, request.Source,
                                                     request.DeviceId, request.Action), cancellationToken);

            return(Unit.Value);
        }
        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);
        }
    }