From 2d8b785fb896724cd0d2400452063845fc7b9267 Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 16 Feb 2021 14:14:52 -0600 Subject: [PATCH] Fix health socket not getting client messages Forgot to resume. Went ahead and did the same for the test plugin although it only sends messages and doesn't receive any. --- src/node/routes/health.ts | 5 +++-- test/test-plugin/src/index.ts | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/node/routes/health.ts b/src/node/routes/health.ts index f38bb0ab..faf1f9c7 100644 --- a/src/node/routes/health.ts +++ b/src/node/routes/health.ts @@ -13,8 +13,8 @@ router.get("/", (req, res) => { export const wsRouter = WsRouter() wsRouter.ws("/", async (req) => { - wss.handleUpgrade(req, req.socket, req.head, (ws) => { - ws.on("message", () => { + wss.handleUpgrade(req, req.ws, req.head, (ws) => { + ws.addEventListener("message", () => { ws.send( JSON.stringify({ event: "health", @@ -23,5 +23,6 @@ wsRouter.ws("/", async (req) => { }), ) }) + req.ws.resume() }) }) diff --git a/test/test-plugin/src/index.ts b/test/test-plugin/src/index.ts index 592ad372..772b59d8 100644 --- a/test/test-plugin/src/index.ts +++ b/test/test-plugin/src/index.ts @@ -28,7 +28,8 @@ export const plugin: cs.Plugin = { wsRouter() { const wr = cs.WsRouter() wr.ws("/test-app", (req) => { - cs.wss.handleUpgrade(req, req.socket, req.head, (ws) => { + cs.wss.handleUpgrade(req, req.ws, req.head, (ws) => { + req.ws.resume() ws.send("hello") }) })