mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-23 03:35:40 +00:00
update version, ping every 5 seconds, only end game if no pings for 20 seconds
This commit is contained in:
@@ -131,7 +131,7 @@ export class Transport {
|
||||
gameID: this.gameID,
|
||||
})))
|
||||
}
|
||||
}, 10000);
|
||||
}, 5 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</svg>
|
||||
</a>
|
||||
<h1 class="text-7xl sm:text-5xl md:text-6xl lg:text-7xl mb-2">OpenFront.io</h1>
|
||||
<h2 class="text-3xl sm:text-4xl md:text-5xl lg:text-6xl mb-4">(v0.12.2)</h2>
|
||||
<h2 class="text-3xl sm:text-4xl md:text-5xl lg:text-6xl mb-4">(v0.12.3)</h2>
|
||||
<div class="flex justify-center items-start">
|
||||
<div class="w-full max-w-3xl p-4 space-y-4">
|
||||
<br />
|
||||
|
||||
@@ -30,6 +30,8 @@ export class GameServer {
|
||||
|
||||
private endTurnIntervalID
|
||||
|
||||
private lastPingUpdate = 0
|
||||
|
||||
constructor(
|
||||
public readonly id: string,
|
||||
public readonly createdAt: number,
|
||||
@@ -77,6 +79,7 @@ export class GameServer {
|
||||
}
|
||||
}
|
||||
if (clientMsg.type == "ping") {
|
||||
this.lastPingUpdate = Date.now()
|
||||
client.lastPing = Date.now()
|
||||
}
|
||||
})
|
||||
@@ -210,7 +213,11 @@ export class GameServer {
|
||||
return GamePhase.Lobby
|
||||
}
|
||||
|
||||
if (this.activeClients.length == 0 && now > this.createdAt + this.config.lobbyLifetime() + 30 * 1000) { // wait at least 30s before ending game
|
||||
const noActive = this.activeClients.length
|
||||
const warmupOver = now > this.createdAt + this.config.lobbyLifetime() + 30 * 1000
|
||||
const noRecentPings = now > this.lastPingUpdate + 20 * 1000
|
||||
|
||||
if (noActive && warmupOver && noRecentPings) {
|
||||
return GamePhase.Finished
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user