From 229ee19949d956777fec44a407ae8c934b2ab71e Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 4 Aug 2025 09:39:20 +0530 Subject: [PATCH] ack role, ws syntax, console --- src/services/secondaryWebsocket.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/services/secondaryWebsocket.js b/src/services/secondaryWebsocket.js index 2670b73..b27710f 100644 --- a/src/services/secondaryWebsocket.js +++ b/src/services/secondaryWebsocket.js @@ -434,6 +434,8 @@ wss.on("connection", (ws) => { return; } + console.log("decoded token ----",decoded) + // Fetch hospital_code from hospitals table const result = await db.query( "SELECT hospital_code FROM hospitals WHERE id = ?", @@ -479,20 +481,20 @@ wss.on("connection", (ws) => { }); }); -function emitEvent(event, data, userId = null) { - if (userId && userSockets.has(userId)) { - const client = userSockets.get(userId); - if (client.readyState === WebSocket.OPEN) { - client.send(JSON.stringify({ event, data })); - } - } else { - wss.clients.forEach((client) => { - if (client.readyState === WebSocket.OPEN) { - client.send(JSON.stringify({ event, data })); - } - }); - } -} +// function emitEvent(event, data, userId = null) { +// if (userId && userSockets.has(userId)) { +// const client = userSockets.get(userId); +// if (client.readyState === WebSocket.OPEN) { +// client.send(JSON.stringify({ event, data })); +// } +// } else { +// wss.clients.forEach((client) => { +// if (client.readyState === WebSocket.OPEN) { +// client.send(JSON.stringify({ event, data })); +// } +// }); +// } +// } server.listen(40520, () => { console.log("📡 Secure WebSocket server listening on wss://backend.spurrinai.com:40520");