fix: use private close clode

This commit is contained in:
Skillz4Killz
2021-04-14 18:06:11 +00:00
committed by GitHub
parent 54ce040120
commit 70a4a1f955
3 changed files with 12 additions and 10 deletions

View File

@@ -16,14 +16,7 @@ export async function createShard(shardId: number) {
socket.onclose = (event) => {
ws.log("CLOSED", { shardId, payload: event });
if (
event.code === 4009 &&
["Resharded!", "Resuming the shard, closing old shard."].includes(
event.reason,
)
) {
return ws.log("CLOSED_RECONNECT", { shardId, payload: event });
}
if (
event.code === 3064 ||
event.reason === "Discordeno Testing Finished! Do Not RESUME!"
@@ -31,6 +24,15 @@ export async function createShard(shardId: number) {
return;
}
if (
event.code === 3065 ||
["Resharded!", "Resuming the shard, closing old shard."].includes(
event.reason,
)
) {
return ws.log("CLOSED_RECONNECT", { shardId, payload: event });
}
// TODO: ENUM FOR THESE CODES?
switch (event.code) {
case 4001:

View File

@@ -13,7 +13,7 @@ export async function resume(shardId: number) {
if (oldShard) {
// HOW TO CLOSE OLD SHARD SOCKET!!!
oldShard.ws.close(4009, "Resuming the shard, closing old shard.");
oldShard.ws.close(3065, "Resuming the shard, closing old shard.");
// STOP OLD HEARTBEAT
clearInterval(oldShard.heartbeat.intervalId);
}

View File

@@ -11,6 +11,6 @@ export async function tellClusterToIdentify(
await ws.identify(shardId, ws.maxShards);
if (oldShard) {
oldShard.ws.close(4009, "Resharded!");
oldShard.ws.close(3065, "Resharded!");
}
}