Compare commits
2 Commits
ed8d148d0a
...
dac037809c
Author | SHA1 | Date | |
---|---|---|---|
dac037809c | |||
6088a2cbd3 |
11
src/main.ts
11
src/main.ts
@ -159,6 +159,17 @@ ws.on("upgrade", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ws.on("close", (event: CloseEvent) => {
|
||||||
|
console.log(`Connection closed: ${event.reason}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
ws.on("open", () => {
|
||||||
|
setInterval(() => {
|
||||||
|
ws.send(JSON.stringify({ type: "ping" }));
|
||||||
|
console.log("Sending ping to keep session alive...");
|
||||||
|
}, 20000);
|
||||||
|
});
|
||||||
|
|
||||||
ws.on("message", async (data) => {
|
ws.on("message", async (data) => {
|
||||||
try {
|
try {
|
||||||
const message: WSEvent = JSON.parse(data.toString("utf-8"));
|
const message: WSEvent = JSON.parse(data.toString("utf-8"));
|
||||||
|
Reference in New Issue
Block a user