feat: support websocket connections from game client #2735
@ -17,7 +17,7 @@ import { InventorySlot } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
				
			|||||||
import { ExportDojoRecipes } from "warframe-public-export-plus";
 | 
					import { ExportDojoRecipes } from "warframe-public-export-plus";
 | 
				
			||||||
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
					import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
 | 
				
			||||||
import type { TInventoryDatabaseDocument } from "../../models/inventoryModels/inventoryModel.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";
 | 
					import { parseFusionTreasure } from "../../helpers/inventoryHelpers.ts";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const sellController: RequestHandler = async (req, res) => {
 | 
					export const sellController: RequestHandler = async (req, res) => {
 | 
				
			||||||
@ -307,10 +307,7 @@ export const sellController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
    res.json({
 | 
					    res.json({
 | 
				
			||||||
        inventoryChanges: inventoryChanges // "inventoryChanges" for this response instead of the usual "InventoryChanges"
 | 
					        inventoryChanges: inventoryChanges // "inventoryChanges" for this response instead of the usual "InventoryChanges"
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    sendWsBroadcastEx({ update_inventory: true }, accountId, parseInt(String(req.query.wsid)));
 | 
					    broadcastInventoryUpdate(req);
 | 
				
			||||||
    if (req.query.wsid) {
 | 
					 | 
				
			||||||
        sendWsBroadcastTo(accountId, { sync_inventory: true });
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface ISellRequest {
 | 
					interface ISellRequest {
 | 
				
			||||||
 | 
				
			|||||||
@ -7,6 +7,7 @@ import { createAccount, createNonce, getUsernameFromEmail, isCorrectPassword } f
 | 
				
			|||||||
import type { IDatabaseAccountJson } from "../types/loginTypes.ts";
 | 
					import type { IDatabaseAccountJson } from "../types/loginTypes.ts";
 | 
				
			||||||
import type { HydratedDocument } from "mongoose";
 | 
					import type { HydratedDocument } from "mongoose";
 | 
				
			||||||
import { logError, logger } from "../utils/logger.ts";
 | 
					import { logError, logger } from "../utils/logger.ts";
 | 
				
			||||||
 | 
					import type { Request } from "express";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let wsServer: WebSocketServer | undefined;
 | 
					let wsServer: WebSocketServer | undefined;
 | 
				
			||||||
let wssServer: 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 => {
 | 
					export const handleNonceInvalidation = (accountId: string): void => {
 | 
				
			||||||
    forEachClient(client => {
 | 
					    forEachClient(client => {
 | 
				
			||||||
        if (client.accountId == accountId) {
 | 
					        if (client.accountId == accountId) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user