using Microsoft.AspNetCore.Components.Server.Circuits;

namespace SelmoStudio.Hmi.Server.SelmoHmi.Helpers
{
    public class CustomCircuitHandler : CircuitHandler
    {
        private readonly ILogger<CustomCircuitHandler> _logger;

        public CustomCircuitHandler(ILogger<CustomCircuitHandler> logger)
        {
            _logger = logger;
        }

        public override Task OnConnectionDownAsync(Circuit circuit, CancellationToken cancellationToken)
        {
            _logger.LogError("Connection down for Circuit ID: {CircuitId}", circuit.Id);

            return base.OnConnectionDownAsync(circuit, cancellationToken);
        }

        public override Task OnConnectionUpAsync(Circuit circuit, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Connection restored for Circuit ID: {CircuitId}", circuit.Id);

            return base.OnConnectionUpAsync(circuit, cancellationToken);
        }
    }


}
