Skip to content

Commit

Permalink
Dispose of client if connection drops
Browse files Browse the repository at this point in the history
  • Loading branch information
insomniac-eeper committed May 30, 2024
1 parent 92f6d7b commit b945748
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions BTTDRichDiscordPresence/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ internal static class Constants
internal static int MaxRetries { get; } = 5;

/// <summary>
/// Delay between retries in milliseconds.
/// Delay between retries in seconds.
/// </summary>
internal static int RetryDelay { get; } = 5000;
internal static int RetryDelay { get; } = 5;

/// <summary>
/// Mapping of map ids to map names.
Expand Down
11 changes: 10 additions & 1 deletion BTTDRichDiscordPresence/DiscordRichPresence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,16 @@ public void SetPresence(
},
};

activityManager.UpdateActivity(presence, resultCallback);
activityManager.UpdateActivity(presence, result =>
{
if (result == Result.NotRunning)
{
this.client?.Dispose();
this.client = null;
this.retries = 0;
}
resultCallback?.Invoke(result);
});
}

/// <summary>
Expand Down

0 comments on commit b945748

Please sign in to comment.