You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
298 B
11 lines
298 B
import { Server } from "ws";
|
|
import { Datagram } from "../types/wsTypes";
|
|
|
|
export function wsSend(wss: Server, data: Datagram) {
|
|
// 广播消息给所有连接的客户端
|
|
wss.clients.forEach(client => {
|
|
if (client.readyState === client.OPEN) {
|
|
client.send(JSON.stringify(data));
|
|
}
|
|
});
|
|
}
|