Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Sep 12, 2024
1 parent 7d6bdb1 commit cd1ec8c
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions JL.Core/Network/WebSocketUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,28 @@ private static void ListenWebSocket(CancellationToken cancellationToken)
}
catch (WebSocketException webSocketException)
{
Utils.Logger.Warning(webSocketException, "WebSocket server is closed unexpectedly");
Utils.Frontend.Alert(AlertLevel.Error, "WebSocket server is closed");

if (!CoreConfigManager.AutoReconnectToWebSocket)
{
if (!CoreConfigManager.CaptureTextFromClipboard)
{
StatsUtils.StatsStopWatch.Stop();
StatsUtils.StopStatsTimer();
}
else
}
else
{
if (CoreConfigManager.CaptureTextFromWebSocket && !cancellationToken.IsCancellationRequested)
{
await Task.Delay(200).ConfigureAwait(false);
}
}

if (CoreConfigManager.CaptureTextFromWebSocket && !cancellationToken.IsCancellationRequested)
{
Utils.Logger.Warning(webSocketException, "WebSocket server is closed unexpectedly");
Utils.Frontend.Alert(AlertLevel.Error, "WebSocket server is closed");
}

break;
}
}
Expand All @@ -108,13 +114,19 @@ private static void ListenWebSocket(CancellationToken cancellationToken)
StatsUtils.StopStatsTimer();
}

Utils.Logger.Warning(webSocketException, "Couldn't connect to the WebSocket server, probably because it is not running");
Utils.Frontend.Alert(AlertLevel.Error, "Couldn't connect to the WebSocket server, probably because it is not running");
if (CoreConfigManager.CaptureTextFromWebSocket && !cancellationToken.IsCancellationRequested)
{
Utils.Logger.Warning(webSocketException, "Couldn't connect to the WebSocket server, probably because it is not running");
Utils.Frontend.Alert(AlertLevel.Error, "Couldn't connect to the WebSocket server, probably because it is not running");
}
}
else
{
Utils.Logger.Verbose(webSocketException, "Couldn't connect to the WebSocket server, probably because it is not running");
await Task.Delay(200).ConfigureAwait(false);
if (CoreConfigManager.CaptureTextFromWebSocket && !cancellationToken.IsCancellationRequested)
{
await Task.Delay(200).ConfigureAwait(false);
}
}
}
}
Expand Down

0 comments on commit cd1ec8c

Please sign in to comment.