Skip to content

Commit

Permalink
fix: properly ping after jitter
Browse files Browse the repository at this point in the history
  • Loading branch information
EnokiUN committed Jun 4, 2023
1 parent d043efe commit eee89f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ const connect = async (userData: UserData, reconnect = false) => {
messages.set([]);
ws = innerWs;
setTimeout(
() => pingInterval = setInterval(() => ws?.send(JSON.stringify({ op: PayloadOP.PING })), payload.d.heartbeat_interval),
() => {
ws?.send(JSON.stringify({ op: PayloadOP.PING }));
pingInterval = setInterval(() => ws?.send(JSON.stringify({ op: PayloadOP.PING })), payload.d.heartbeat_interval);
},
payload.d.heartbeat_interval * Math.random()
);
}
Expand Down

0 comments on commit eee89f6

Please sign in to comment.