Fixed reconnection causing unhandled exceptions

This commit is contained in:
Tom 2024-08-12 20:10:11 +00:00
parent 1d43515fb9
commit a38e08c14d
4 changed files with 7 additions and 7 deletions

View File

@ -62,7 +62,7 @@ namespace TwitchChatTTS.Hermes.Socket
} }
public async Task Connect() public override async Task Connect()
{ {
lock (_lock) lock (_lock)
{ {
@ -263,7 +263,7 @@ namespace TwitchChatTTS.Hermes.Socket
_logger.Warning("Hermes websocket client disconnected."); _logger.Warning("Hermes websocket client disconnected.");
_heartbeatTimer.Enabled = false; _heartbeatTimer.Enabled = false;
await Reconnect(_backoff, async () => await Connect()); await Reconnect(_backoff);
}; };
} }

View File

@ -84,7 +84,7 @@ namespace TwitchChatTTS.OBS.Socket
_sourceIds.Clear(); _sourceIds.Clear();
} }
public async Task Connect() public override async Task Connect()
{ {
if (string.IsNullOrWhiteSpace(URL)) if (string.IsNullOrWhiteSpace(URL))
{ {

View File

@ -85,7 +85,7 @@ namespace TwitchChatTTS.Seven.Socket
URL = $"{SevenApiClient.WEBSOCKET_URL}@emote_set.*<object_id={_user.SevenEmoteSetId}>"; URL = $"{SevenApiClient.WEBSOCKET_URL}@emote_set.*<object_id={_user.SevenEmoteSetId}>";
} }
public async Task Connect() public override async Task Connect()
{ {
if (string.IsNullOrEmpty(URL)) if (string.IsNullOrEmpty(URL))
{ {
@ -137,7 +137,7 @@ namespace TwitchChatTTS.Seven.Socket
Task.Run(async () => Task.Run(async () =>
{ {
await Reconnect(_backoff, async () => await Connect()); await Reconnect(_backoff);
await Task.Delay(TimeSpan.FromMilliseconds(500)); await Task.Delay(TimeSpan.FromMilliseconds(500));
if (Connected && ConnectionDetails?.SessionId != null) if (Connected && ConnectionDetails?.SessionId != null)

View File

@ -111,7 +111,7 @@ namespace TwitchChatTTS.Twitch.Socket
}; };
} }
public async Task Connect() public override async Task Connect()
{ {
if (string.IsNullOrWhiteSpace(URL)) if (string.IsNullOrWhiteSpace(URL))
{ {
@ -123,7 +123,7 @@ namespace TwitchChatTTS.Twitch.Socket
await ConnectAsync(URL); await ConnectAsync(URL);
} }
public async Task Reconnect() => await Reconnect(_backoff, async () => await Connect()); public async Task Reconnect() => await Reconnect(_backoff);
public void Identify(string sessionId) public void Identify(string sessionId)
{ {