We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e9dfaf4 commit bc6b2f6Copy full SHA for bc6b2f6
src/server/GameServer.ts
@@ -648,6 +648,21 @@ export class GameServer {
648
}
649
650
this.activeClients = alive;
651
+ // Clean up stale spectators
652
+ const aliveSpectators: Client[] = [];
653
+ for (const spectator of this.spectators) {
654
+ if (now - spectator.lastPing > 60_000) {
655
+ this.log.info("spectator no pings, terminating", {
656
+ clientID: spectator.clientID,
657
+ });
658
+ if (spectator.ws.readyState === WebSocket.OPEN) {
659
+ spectator.ws.close(1000, "no heartbeats received");
660
+ }
661
+ } else {
662
+ aliveSpectators.push(spectator);
663
664
665
+ this.spectators = aliveSpectators;
666
if (now > this.createdAt + this.maxGameDuration) {
667
this.log.warn("game past max duration", {
668
gameID: this.id,
0 commit comments