Skip to content

Commit

Permalink
Remoe RPC update timer
Browse files Browse the repository at this point in the history
  • Loading branch information
DJDavid98 committed Mar 28, 2023
1 parent b88f761 commit 5b30c88
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
16 changes: 3 additions & 13 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using IPA;
using System;
using System.Text;
using System.Threading;
using UnityEngine;
using IPALogger = IPA.Logging.Logger;

Expand All @@ -17,7 +16,6 @@ public class Plugin

private DiscordInstance _discord;
private const long DiscordClientId = 1028340906740420711;
private Timer _updateTimer;

[Init]
/// <summary>
Expand Down Expand Up @@ -46,15 +44,6 @@ public void OnApplicationStart()
modId = nameof(bsrpc),
modName = nameof(bsrpc),
});

SetUpdateTimer(0);
}

// Update rich presence regularly on a schedule even if the update events are not fired
private void SetUpdateTimer(int debounceMs = 500)
{
_updateTimer?.Dispose();
_updateTimer = new Timer((e) => UpdateRichPresence(), null, debounceMs, 5000);
}

private void UpdateRichPresence(string jsonData)
Expand All @@ -66,7 +55,6 @@ private void UpdateRichPresence()
var activity = GetActivityData();

_discord.UpdateActivity(activity);
SetUpdateTimer();
}

private string GetReadableDifficulty(string originalDifficulty)
Expand Down Expand Up @@ -325,7 +313,9 @@ private long DateTimeToUnixTimestamp(DateTime ticks)
[OnExit]
public void OnApplicationQuit()
{

MapData.Instance.OnUpdate -= UpdateRichPresence;
LiveData.Instance.OnUpdate -= UpdateRichPresence;
_discord.DestroyInstance();
}
}
}
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.4")]
[assembly: AssemblyFileVersion("1.0.4")]
[assembly: AssemblyVersion("1.0.5")]
[assembly: AssemblyFileVersion("1.0.5")]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Discord Rich Presence support for Beat Saber. No customization options whatsoeve
## Dependencies

* BSIPA v4.2.2 (ModAssistant)
* DiscordCore v1.0.10 (https://github.com/FizzyApple12/DiscordCore/releases/tag/v1.0.10)
* DiscordCore v3.0.0 (https://github.com/DJDavid98/DiscordCore/releases/tag/v3.0.0)
* DataPuller v2.1.1 (https://github.com/ReadieFur/BSDataPuller/releases/tag/2.1.1)
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"id": "bsrpc",
"name": "bsrpc",
"author": "DJDavid98",
"version": "1.0.4",
"version": "1.0.5",
"description": "Discord Rich Presence integration for Beat Saber",
"gameVersion": "1.28.0",
"dependsOn": {
"BSIPA": "^4.2.2",
"DataPuller": "^2.1.1",
"DiscordCore": "^1.0.10"
"DiscordCore": "^3.0.0"
},
"links": {
"project-source": "https://github.com/DJDavid98/bsrpc"
Expand Down

0 comments on commit 5b30c88

Please sign in to comment.