ack role, ws syntax, console

This commit is contained in:
Ubuntu 2025-08-04 09:39:20 +05:30
parent e000aac57b
commit 229ee19949

View File

@ -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");