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.
This commit is contained in:
Asher 2021-02-16 14:14:52 -06:00
parent 7f80d152d3
commit 2d8b785fb8
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
2 changed files with 5 additions and 3 deletions

View File

@ -13,8 +13,8 @@ router.get("/", (req, res) => {
export const wsRouter = WsRouter() export const wsRouter = WsRouter()
wsRouter.ws("/", async (req) => { wsRouter.ws("/", async (req) => {
wss.handleUpgrade(req, req.socket, req.head, (ws) => { wss.handleUpgrade(req, req.ws, req.head, (ws) => {
ws.on("message", () => { ws.addEventListener("message", () => {
ws.send( ws.send(
JSON.stringify({ JSON.stringify({
event: "health", event: "health",
@ -23,5 +23,6 @@ wsRouter.ws("/", async (req) => {
}), }),
) )
}) })
req.ws.resume()
}) })
}) })

View File

@ -28,7 +28,8 @@ export const plugin: cs.Plugin = {
wsRouter() { wsRouter() {
const wr = cs.WsRouter() const wr = cs.WsRouter()
wr.ws("/test-app", (req) => { 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") ws.send("hello")
}) })
}) })