add broadcastInventoryUpdate

This commit is contained in:
Sainan 2025-09-08 05:16:06 +02:00
parent 6fb9ae2366
commit 047b21d776
2 changed files with 11 additions and 5 deletions

View File

@ -17,7 +17,7 @@ import { InventorySlot } from "../../types/inventoryTypes/inventoryTypes.ts";
import { ExportDojoRecipes } from "warframe-public-export-plus";
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
import type { TInventoryDatabaseDocument } from "../../models/inventoryModels/inventoryModel.ts";
import { sendWsBroadcastEx, sendWsBroadcastTo } from "../../services/wsService.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
import { parseFusionTreasure } from "../../helpers/inventoryHelpers.ts";
export const sellController: RequestHandler = async (req, res) => {
@ -307,10 +307,7 @@ export const sellController: RequestHandler = async (req, res) => {
res.json({
inventoryChanges: inventoryChanges // "inventoryChanges" for this response instead of the usual "InventoryChanges"
});
sendWsBroadcastEx({ update_inventory: true }, accountId, parseInt(String(req.query.wsid)));
if (req.query.wsid) {
sendWsBroadcastTo(accountId, { sync_inventory: true });
}
broadcastInventoryUpdate(req);
};
interface ISellRequest {

View File

@ -7,6 +7,7 @@ import { createAccount, createNonce, getUsernameFromEmail, isCorrectPassword } f
import type { IDatabaseAccountJson } from "../types/loginTypes.ts";
import type { HydratedDocument } from "mongoose";
import { logError, logger } from "../utils/logger.ts";
import type { Request } from "express";
let wsServer: WebSocketServer | undefined;
let wssServer: WebSocketServer | undefined;
@ -230,6 +231,14 @@ export const sendWsBroadcastEx = (data: IWsMsgToClient, accountId?: string, excl
});
};
export const broadcastInventoryUpdate = (req: Request): void => {
const accountId = req.query.accountId as string;
sendWsBroadcastEx({ update_inventory: true }, accountId, parseInt(String(req.query.wsid)));
if (req.query.wsid) {
sendWsBroadcastTo(accountId, { sync_inventory: true });
}
};
export const handleNonceInvalidation = (accountId: string): void => {
forEachClient(client => {
if (client.accountId == accountId) {