mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-18 22:33:50 +02:00
Fix Discord RPC 3
This commit is contained in:
19
Discord.cs
19
Discord.cs
@@ -17,6 +17,7 @@ namespace VRCX
|
||||
private readonly RichPresence m_Presence;
|
||||
private DiscordRpcClient m_Client;
|
||||
private Timer m_Timer;
|
||||
private bool m_Active;
|
||||
public static string DiscordAppId;
|
||||
|
||||
static Discord()
|
||||
@@ -61,7 +62,7 @@ namespace VRCX
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (m_Client == null)
|
||||
if (m_Client == null && m_Active)
|
||||
{
|
||||
m_Client = new DiscordRpcClient(DiscordAppId);
|
||||
if (m_Client.Initialize() == false)
|
||||
@@ -71,6 +72,12 @@ namespace VRCX
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Client != null && !m_Active)
|
||||
{
|
||||
m_Client.Dispose();
|
||||
m_Client = null;
|
||||
}
|
||||
|
||||
if (m_Client != null && !m_Lock.IsWriteLockHeld)
|
||||
{
|
||||
m_Lock.EnterReadLock();
|
||||
@@ -86,14 +93,10 @@ namespace VRCX
|
||||
}
|
||||
}
|
||||
|
||||
public void SetInactive()
|
||||
public bool SetActive(bool active)
|
||||
{
|
||||
if (m_Client != null)
|
||||
{
|
||||
m_Client.ClearPresence();
|
||||
m_Client.Dispose();
|
||||
m_Client = null;
|
||||
}
|
||||
m_Active = active;
|
||||
return m_Active;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/1225052/best-way-to-shorten-utf8-string-based-on-byte-length
|
||||
|
||||
Reference in New Issue
Block a user