Example #1
0
        private async Task HandleReconnectAttemptsAsync(CancellationToken stoppingToken)
        {
            for (int reconnectAttempt = 0; reconnectAttempt < maxReconnectAttempts; reconnectAttempt++)
            {
                _logger.LogInformation($"Reconnect attempt {reconnectAttempt} of {maxReconnectAttempts}.");
                try
                {
                    await _ircClient.ReconnectAsync();

                    break;
                }
                catch (SocketException se)
                {
                    _logger.LogError(se, "The following socket exception occurred while attempting a reconnect.");
                    await Task.Delay(reconnectWaitTime, stoppingToken);
                }
            }
        }