add sendWsBroadcastToWebui

This commit is contained in:
Sainan 2025-09-08 05:57:39 +02:00
parent 9a144e17f7
commit b812cec358

View File

@ -240,6 +240,19 @@ export const sendWsBroadcastEx = (data: IWsMsgToClient, accountId: string | unde
});
};
export const sendWsBroadcastToWebui = (
data: IWsMsgToClient,
accountId: string | undefined,
excludeWsid: number
): void => {
const msg = JSON.stringify(data);
forEachClient(client => {
if (!client.isGame && (!accountId || client.accountId == accountId) && client.id != excludeWsid) {
client.send(msg);
}
});
};
export const broadcastInventoryUpdate = (req: Request): void => {
const accountId = req.query.accountId as string;
if (req.query.wsid) {
@ -251,7 +264,7 @@ export const broadcastInventoryUpdate = (req: Request): void => {
);
} else {
// for game requests, let all webui tabs know
sendWsBroadcastEx({ update_inventory: true }, accountId, parseInt(String(req.query.wsid))); // TODO: exclude game ws from this somehow
sendWsBroadcastToWebui({ update_inventory: true }, accountId, parseInt(String(req.query.wsid)));
}
};