Skip to content
This repository has been archived by the owner on Mar 25, 2022. It is now read-only.

Commit

Permalink
Fix timer not rescheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
VolcanicArts committed Mar 8, 2022
1 parent a2e6ed1 commit 286c498
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion VRCHypeRate/Client/HypeRateClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,14 +73,15 @@ 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? _)
{
Logger.Log("Sending heartbeat to websocket");
var heartBeatModel = new WebSocketHeartBeatModel();
webSocket.Send(JsonConvert.SerializeObject(heartBeatModel));
heartBeatTimer.Change(HeartbeatInternal, Timeout.Infinite);
}

private void sendJoinChannel()
Expand Down

0 comments on commit 286c498

Please sign in to comment.