add closeWS function

This commit is contained in:
ITOH
2021-04-15 16:46:44 +02:00
parent 2c97964f0f
commit 8c52abce7f
6 changed files with 18 additions and 12 deletions
+3 -2
View File
@@ -1,3 +1,4 @@
import { closeWS } from "./close_ws.ts";
import { ws } from "./ws.ts";
/** Allows users to hook in and change to communicate to different clusters across different servers or anything they like. For example using redis pubsub to talk to other servers. */
@@ -10,7 +11,7 @@ export async function tellClusterToIdentify(
const oldShard = ws.shards.get(shardId);
await ws.identify(shardId, ws.maxShards);
if (oldShard?.ws.readyState === WebSocket.OPEN) {
oldShard.ws.close(3065, "Resharded!");
if (oldShard) {
closeWS(oldShard.ws, 3063, "Resharded!");
}
}