From 693a448972685ef3fbb376fa13303c2fad16ce02 Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 12 Aug 2024 17:55:28 +0000 Subject: [PATCH] Added Twitch exponential backoff for reconnecting. --- Twitch/Socket/TwitchConnectionManager.cs | 2 +- Twitch/Socket/TwitchWebsocketClient.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Twitch/Socket/TwitchConnectionManager.cs b/Twitch/Socket/TwitchConnectionManager.cs index 8cf68dd..b2571a8 100644 --- a/Twitch/Socket/TwitchConnectionManager.cs +++ b/Twitch/Socket/TwitchConnectionManager.cs @@ -98,7 +98,7 @@ namespace TwitchChatTTS.Twitch.Socket if (reconnecting) { var newClient = GetWorkingClient(); - await newClient.Connect(); + await newClient.Reconnect(); } } diff --git a/Twitch/Socket/TwitchWebsocketClient.cs b/Twitch/Socket/TwitchWebsocketClient.cs index 46e6c0a..33b4ddf 100644 --- a/Twitch/Socket/TwitchWebsocketClient.cs +++ b/Twitch/Socket/TwitchWebsocketClient.cs @@ -122,6 +122,8 @@ namespace TwitchChatTTS.Twitch.Socket await ConnectAsync(URL); } + public async Task Reconnect() => await Reconnect(_backoff, async () => await Connect()); + public void Identify(string sessionId) { Identified = true;