update thing
This commit is contained in:
parent
ba683ad1f9
commit
ea4c03ce05
|
@ -19,9 +19,11 @@ namespace PluralRichPresence.Discord
|
|||
private const string DEFAULT_APPLICATION_ID = "1163661006719963158";
|
||||
private static HttpClient client = new HttpClient();
|
||||
|
||||
const int ACTIVITY_TIMEOUT = 110000;
|
||||
private SystemMember? lastFronter = null;
|
||||
private int? seq = null;
|
||||
private Timer? keepAliveTimer = null;
|
||||
private Timer? activityTimer = null;
|
||||
private AWebSocket? wSock = null;
|
||||
private ManualResetEvent waitForConnect = new ManualResetEvent(false);
|
||||
private int heartBeatInterval = 0;
|
||||
|
@ -37,7 +39,11 @@ namespace PluralRichPresence.Discord
|
|||
switch ((int)jsonData.op)
|
||||
{
|
||||
case 0:
|
||||
if (jsonData.t == "READY") waitForConnect.Set();
|
||||
if (jsonData.t == "READY")
|
||||
{
|
||||
waitForConnect.Set();
|
||||
activityTimer = new Timer((TimerCallback) => { if(lastFronter is not null) SetFronter(lastFronter); }, null, ACTIVITY_TIMEOUT, ACTIVITY_TIMEOUT);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
_ = sendKeepAlive();
|
||||
|
@ -48,7 +54,7 @@ namespace PluralRichPresence.Discord
|
|||
case 10:
|
||||
sendKeepAlive().Wait();
|
||||
heartBeatInterval = jsonData.d.heartbeat_interval;
|
||||
keepAliveTimer = new Timer((TimerCallback) => { _ = sendKeepAlive(); }, null, heartBeatInterval, 0);
|
||||
keepAliveTimer = new Timer((TimerCallback) => { _ = sendKeepAlive(); }, null, heartBeatInterval, heartBeatInterval);
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -158,13 +164,9 @@ namespace PluralRichPresence.Discord
|
|||
gatewayOp.op = 1;
|
||||
gatewayOp.d = seq;
|
||||
|
||||
Logger.Debug("SENDING KEEP ALIVE MESSAGE");
|
||||
|
||||
if (wSock is not null)
|
||||
await wSock.SendText(JsonConvert.SerializeObject(gatewayOp));
|
||||
|
||||
if(keepAliveTimer is not null)
|
||||
keepAliveTimer.Change(this.heartBeatInterval, 0);
|
||||
}
|
||||
|
||||
public void SetFronter(SystemMember sysMember)
|
||||
|
|
|
@ -90,6 +90,7 @@ namespace PluralRichPresence
|
|||
}
|
||||
public static async Task Main(string[] args)
|
||||
{
|
||||
Logger.Info("Connecting to Discord ...");
|
||||
discordSetter = new DiscordClient(Config.GetEntry("DISCORD_TOKEN"));
|
||||
//discordSetter = new DiscordRpc();
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<History>True|2024-03-15T06:01:46.3092686Z;True|2023-12-28T23:24:43.7413097+13:00;True|2023-12-28T23:24:32.3866287+13:00;True|2023-12-28T23:22:28.7251892+13:00;True|2023-12-28T21:45:45.2231538+13:00;True|2023-12-28T21:00:25.2444119+13:00;True|2023-12-28T20:56:12.0172711+13:00;True|2023-12-28T20:54:22.1893325+13:00;True|2023-12-28T20:53:03.6353258+13:00;True|2023-11-19T17:13:26.6652642+13:00;True|2023-11-05T19:18:40.8205304+13:00;True|2023-11-05T19:17:01.7660736+13:00;True|2023-11-05T19:11:32.6382930+13:00;True|2023-11-05T19:11:09.6820258+13:00;False|2023-11-05T19:10:42.2427675+13:00;True|2023-10-18T14:13:41.8203499+13:00;True|2023-10-18T14:05:36.8381808+13:00;True|2023-10-17T21:30:38.9682339+13:00;</History>
|
||||
<History>True|2024-03-15T06:19:04.1185534Z;True|2024-03-15T19:01:46.3092686+13:00;True|2023-12-28T23:24:43.7413097+13:00;True|2023-12-28T23:24:32.3866287+13:00;True|2023-12-28T23:22:28.7251892+13:00;True|2023-12-28T21:45:45.2231538+13:00;True|2023-12-28T21:00:25.2444119+13:00;True|2023-12-28T20:56:12.0172711+13:00;True|2023-12-28T20:54:22.1893325+13:00;True|2023-12-28T20:53:03.6353258+13:00;True|2023-11-19T17:13:26.6652642+13:00;True|2023-11-05T19:18:40.8205304+13:00;True|2023-11-05T19:17:01.7660736+13:00;True|2023-11-05T19:11:32.6382930+13:00;True|2023-11-05T19:11:09.6820258+13:00;False|2023-11-05T19:10:42.2427675+13:00;True|2023-10-18T14:13:41.8203499+13:00;True|2023-10-18T14:05:36.8381808+13:00;True|2023-10-17T21:30:38.9682339+13:00;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue