feat: support websocket connections from game client #2735
@ -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)));
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user