Monitoring client connections (#941)

## Description:
Disconnected client detection :
If a client haven't send a ping to the server since more than 30 seconds
They will then be marked disconnected with a dedicated icon.
No action are yet taken, this allows for extensive in-game test before
adding the *consequences* of the player leaving the game.
I also added extensive unit tests, lessening the risk of regression for
the future.


![image](https://github.com/user-attachments/assets/884e5e99-15e8-4544-bd52-7524542cc82a)



## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [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

## Please put your Discord username so you can be contacted if a bug or
regression is found:
theodoreleon.aetarax

---------

Co-authored-by: evanpelle <evanpelle@gmail.com>
This commit is contained in:
Théodore Léon
2025-06-06 22:30:23 +02:00
committed by evanpelle
parent 936df2b171
commit 9f9fa9ca8b
12 changed files with 287 additions and 2 deletions
+3
View File
@@ -15,6 +15,7 @@ import { DonateTroopsExecution } from "./DonateTroopExecution";
import { EmbargoExecution } from "./EmbargoExecution";
import { EmojiExecution } from "./EmojiExecution";
import { FakeHumanExecution } from "./FakeHumanExecution";
import { MarkDisconnectedExecution } from "./MarkDisconnectedExecution";
import { MoveWarshipExecution } from "./MoveWarshipExecution";
import { NoOpExecution } from "./NoOpExecution";
import { QuickChatExecution } from "./QuickChatExecution";
@@ -120,6 +121,8 @@ export class Executor {
intent.quickChatKey,
intent.variables ?? {},
);
case "mark_disconnected":
return new MarkDisconnectedExecution(player, intent.isDisconnected);
default:
throw new Error(`intent type ${intent} not found`);
}
@@ -0,0 +1,24 @@
import { Execution, Game, Player } from "../game/Game";
export class MarkDisconnectedExecution implements Execution {
constructor(
private player: Player,
private isDisconnected: boolean,
) {}
init(mg: Game, ticks: number): void {
this.player.markDisconnected(this.isDisconnected);
}
tick(ticks: number): void {
return;
}
isActive(): boolean {
return false;
}
activeDuringSpawnPhase(): boolean {
return false;
}
}