diff --git a/src/main.ts b/src/main.ts index 56cab7a..f1ead82 100644 --- a/src/main.ts +++ b/src/main.ts @@ -159,6 +159,16 @@ ws.on("upgrade", () => { ); }); +ws.on("close", (event: CloseEvent) => { + console.log(`Connection closed: ${event.reason}`); +}); + +ws.on("open", () => { + setInterval(() => { + ws.send(JSON.stringify({ type: "ping" })); + }, 20000); +}); + ws.on("message", async (data) => { try { const message: WSEvent = JSON.parse(data.toString("utf-8"));