Skip to content

Commit bc6b2f6

Browse files
committed
fixed comments which are outside the diff
1 parent e9dfaf4 commit bc6b2f6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/server/GameServer.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,21 @@ export class GameServer {
648648
}
649649
}
650650
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;
651666
if (now > this.createdAt + this.maxGameDuration) {
652667
this.log.warn("game past max duration", {
653668
gameID: this.id,

0 commit comments

Comments
 (0)