From 286c49857892a6f0ec02543dcbb2a3e0fe8e96a6 Mon Sep 17 00:00:00 2001 From: VolcanicArts Date: Tue, 8 Mar 2022 07:26:19 +0000 Subject: [PATCH] Fix timer not rescheduling --- VRCHypeRate/Client/HypeRateClient.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/VRCHypeRate/Client/HypeRateClient.cs b/VRCHypeRate/Client/HypeRateClient.cs index ab4ad3c..7dd1aa7 100644 --- a/VRCHypeRate/Client/HypeRateClient.cs +++ b/VRCHypeRate/Client/HypeRateClient.cs @@ -15,6 +15,7 @@ public class HypeRateClient private const string URI = "wss://app.hyperate.io/socket/websocket?token="; private static readonly string OSCURI = IPAddress.Loopback.ToString(); private const int OSCPort = 9000; + private const int HeartbeatInternal = 30000; private readonly string Id; private readonly string ApiKey; @@ -72,7 +73,7 @@ private void WsConnected(object? sender, EventArgs e) private void initHeartBeat() { - heartBeatTimer = new Timer(sendHeartBeat, null, 30000, Timeout.Infinite); + heartBeatTimer = new Timer(sendHeartBeat, null, HeartbeatInternal, Timeout.Infinite); } private void sendHeartBeat(object? _) @@ -80,6 +81,7 @@ private void sendHeartBeat(object? _) Logger.Log("Sending heartbeat to websocket"); var heartBeatModel = new WebSocketHeartBeatModel(); webSocket.Send(JsonConvert.SerializeObject(heartBeatModel)); + heartBeatTimer.Change(HeartbeatInternal, Timeout.Infinite); } private void sendJoinChannel()