Exemplo n.º 1
0
            public async Task Handle(DoorOpenedNotification notification, CancellationToken cancellationToken)
            {
                _logger.LogInformation("Door opened");

                if (_state.Armed || _state.Locked)
                {
                    await _serviceEventClient.PublishEvent(new UnauthorizedAccessEvent());

                    await _ledService.ToggleRedLedOn();

                    // In a real-world scenario, this would be going on until manually stopped.

                    await _buzzerService
                    .BuzzAsync(_state.BuzzTime)
                    .ConfigureAwait(false);

                    await _ledService.ToggleOff();

                    return;
                }

                await _serviceEventClient.PublishEvent(new AccessControl.Contracts.Events.AccessEvent());
            }