sync inventory when focus schools were unlocked
This commit is contained in:
parent
f2dcb50110
commit
a1362aaf9b
@ -62,6 +62,7 @@ interface IWsMsgFromClient {
|
|||||||
nonce: number;
|
nonce: number;
|
||||||
};
|
};
|
||||||
logout?: boolean;
|
logout?: boolean;
|
||||||
|
sync_inventory?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IWsMsgToClient {
|
interface IWsMsgToClient {
|
||||||
@ -168,6 +169,7 @@ const wsOnConnect = (ws: WebSocket, req: http.IncomingMessage): void => {
|
|||||||
}
|
}
|
||||||
if (data.logout) {
|
if (data.logout) {
|
||||||
const accountId = (ws as IWsCustomData).accountId;
|
const accountId = (ws as IWsCustomData).accountId;
|
||||||
|
if (accountId) {
|
||||||
(ws as IWsCustomData).accountId = undefined;
|
(ws as IWsCustomData).accountId = undefined;
|
||||||
await Account.updateOne(
|
await Account.updateOne(
|
||||||
{
|
{
|
||||||
@ -179,6 +181,13 @@ const wsOnConnect = (ws: WebSocket, req: http.IncomingMessage): void => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (data.sync_inventory) {
|
||||||
|
const accountId = (ws as IWsCustomData).accountId;
|
||||||
|
if (accountId) {
|
||||||
|
sendWsBroadcastToGame(accountId, { sync_inventory: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError(e as Error, `processing websocket message`);
|
logError(e as Error, `processing websocket message`);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2324,6 +2324,9 @@ function doUnlockAllFocusSchools() {
|
|||||||
toast(loc("code_focusAllUnlocked"));
|
toast(loc("code_focusAllUnlocked"));
|
||||||
} else {
|
} else {
|
||||||
toast(loc("code_focusUnlocked").split("|COUNT|").join(Object.keys(missingFocusUpgrades).length));
|
toast(loc("code_focusUnlocked").split("|COUNT|").join(Object.keys(missingFocusUpgrades).length));
|
||||||
|
if (ws_is_open) {
|
||||||
|
window.ws.send(JSON.stringify({ sync_inventory: true }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user