This commit is contained in:
AdisakKanthawilang 2025-03-07 12:36:03 +07:00
parent 9d167d0050
commit 3344826fb9
2 changed files with 26 additions and 20 deletions

View file

@ -1,16 +1,16 @@
// import { WebSocket } from "ws";
// import { wss } from "../app";
import { WebSocket } from "ws";
import { wss } from "../app";
// export async function sendWebSocket(data:any){
// wss.clients.forEach((client: any) => {
// if (client.readyState === WebSocket.OPEN) {
// const message = JSON.stringify(data);
// console.log("📤 Sending data to client:", message);
// client.send(message, (err:any) => {
// if (err) {
// console.error("❌ Error sending message:", err);
// }
// });
// }
// });
// }
export async function sendWebSocket(data:any){
wss.clients.forEach((client: any) => {
if (client.readyState === WebSocket.OPEN) {
const message = JSON.stringify(data);
console.log("📤 Sending data to client:", message);
client.send(message, (err:any) => {
if (err) {
console.error("❌ Error sending message:", err);
}
});
}
});
}