feat: support websocket connections from game client #2735

Merged
Sainan merged 19 commits from client-ws into main 2025-09-10 00:00:10 -07:00
Showing only changes of commit ae9030d2ce - Show all commits

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 => { export const broadcastInventoryUpdate = (req: Request): void => {
const accountId = req.query.accountId as string; const accountId = req.query.accountId as string;
if (req.query.wsid) { if (req.query.wsid) {
@ -251,7 +264,7 @@ export const broadcastInventoryUpdate = (req: Request): void => {
); );
} else { } else {
// for game requests, let all webui tabs know // 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)));
} }
}; };