mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-19 06:16:41 +00:00
Remove clientID, persistentID, gameID from ClientBaseMessageSchema, TurnSchema (#666)
## Description: Remove the devils `clientID`, `persistentID`, and `gameID` from `ClientBaseMessageSchema`, as well as `gameID` from `TurnSchema`. These values are already known through the `Client` object that is hoisted into the relevant handler. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
This commit is contained in:
co-authored by
Scott Anderson
parent
a62bbbc6b1
commit
cb9b5a7a17
+10
-31
@@ -128,10 +128,14 @@ export class GameServer {
|
||||
(c) => c.clientID == client.clientID,
|
||||
);
|
||||
if (existing != null) {
|
||||
if (client.persistentID != existing.persistentID) {
|
||||
console.warn(
|
||||
`client ${client.clientID} cannot rejoin game, persistent id mismatch: exist pid: ${existing.persistentID}, new pid: ${client.persistentID}`,
|
||||
);
|
||||
if (client.persistentID !== existing.persistentID) {
|
||||
this.log.error("persistent ids do not match", {
|
||||
clientID: client.clientID,
|
||||
clientIP: client.ip,
|
||||
clientPersistentID: client.persistentID,
|
||||
existingIP: existing.ip,
|
||||
existingPersistentID: existing.persistentID,
|
||||
});
|
||||
return;
|
||||
}
|
||||
existing.ws.removeAllListeners("message");
|
||||
@@ -154,34 +158,10 @@ export class GameServer {
|
||||
} catch (error) {
|
||||
throw Error(`error parsing schema for ${client.ip}`);
|
||||
}
|
||||
if (this.allClients.has(clientMsg.clientID)) {
|
||||
const client = this.allClients.get(clientMsg.clientID);
|
||||
if (client.persistentID != clientMsg.persistentID) {
|
||||
this.log.warn(
|
||||
`Client ID ${clientMsg.clientID} sent incorrect id ${clientMsg.persistentID}, does not match persistent id ${client.persistentID}`,
|
||||
{
|
||||
clientID: clientMsg.clientID,
|
||||
persistentID: clientMsg.persistentID,
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Clear out persistent id to make sure it doesn't get sent to other clients.
|
||||
clientMsg.persistentID = null;
|
||||
|
||||
if (clientMsg.type == "intent") {
|
||||
if (clientMsg.gameID != this.id) {
|
||||
this.log.warn("client sent to wrong game", {
|
||||
clientID: clientMsg.clientID,
|
||||
persistentID: clientMsg.persistentID,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (clientMsg.intent.clientID != clientMsg.clientID) {
|
||||
if (clientMsg.intent.clientID != client.clientID) {
|
||||
this.log.warn(
|
||||
`client id mismatch, client message: ${clientMsg.clientID}, intent client id ${clientMsg.intent.clientID}`,
|
||||
`client id mismatch, client: ${client.clientID}, intent: ${clientMsg.intent.clientID}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -335,7 +315,6 @@ export class GameServer {
|
||||
private endTurn() {
|
||||
const pastTurn: Turn = {
|
||||
turnNumber: this.turns.length,
|
||||
gameID: this.id,
|
||||
intents: this.intents,
|
||||
};
|
||||
this.turns.push(pastTurn);
|
||||
|
||||
Reference in New Issue
Block a user