Skip to content

Commit

Permalink
Added some error handling specific to the bot listener thread
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlOfDuty committed Oct 26, 2024
1 parent ec0bff9 commit d143d1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions SCPDiscordPlugin/BotListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public BotListener()

Thread.Sleep(500);
}
catch (ThreadAbortException)
{
// Break out of the loop if the thread is aborted
break;
}
catch (Exception ex)
{
Logger.Error("BotListener Error: " + ex);
Expand Down
2 changes: 2 additions & 0 deletions SCPDiscordPlugin/NetworkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ private static void Connect()
{
if (socket != null && socket.IsBound)
{
Logger.Warn("Aborting existing message thread...");
messageThread?.Abort();
socket.Close();
Thread.Sleep(500);
}

socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Expand Down

0 comments on commit d143d1d

Please sign in to comment.