small fixes

This commit is contained in:
Skillz
2020-10-14 21:17:15 -04:00
parent d68f5d8ea0
commit 4060dbee2b
2 changed files with 17 additions and 3 deletions

View File

@@ -211,14 +211,27 @@ async function heartbeat(
return;
}
if (!heartbeating.has(shard.id)) heartbeating.set(shard.id, false);
else {
if (heartbeating.has(shard.id)) {
const receivedACK = heartbeating.get(shard.id);
// If a ACK response was not received since last heartbeat, issue invalid session close
if (!receivedACK) {
shard.socket.send(JSON.stringify({ op: 4009 }));
eventHandlers.debug?.(
{
type: "heartbeatStopped",
data: {
interval,
previousSequenceNumber: shard.previousSequenceNumber,
shardID: shard.id,
},
},
);
return shard.socket.send(JSON.stringify({ op: 4009 }));
}
}
// Set it to false as we are issuing a new heartbeat
heartbeating.set(shard.id, false);
shard.socket.send(
JSON.stringify(
{ op: GatewayOpcode.Heartbeat, d: shard.previousSequenceNumber },

View File

@@ -64,6 +64,7 @@ export interface DebugArg {
| "requestManagerFetched"
| "requestMembersProcessing"
| "heartbeat"
| "heartbeatStopped"
| "createShard"
| "invalidSession"
| "reconnect"