Remove the outdated-app check on connect and its messages

- Drop the protocol version gate in the game handshake and its banner
- Admit spectators of any version and drop the update-required dialogs
- Remove the related strings and tests; reword the unverified warning
This commit is contained in:
2026-11-08 11:11:01 +02:00
parent f8fce1675f
commit 2751461fa0
20 changed files with 17 additions and 99 deletions
@@ -27,7 +27,7 @@ class SpectatorClient(
) {
data class Timing(val connectTimeoutMs: Int = 5_000, val silenceTimeoutMs: Int = 15_000)
enum class Failure { UNREACHABLE, FULL, NO_GAME, UPDATE_THIS_APP, UPDATE_HOST_APP }
enum class Failure { UNREACHABLE, FULL, NO_GAME }
sealed class Event {
data class Joined(val welcome: SpectatorMessage.Welcome) : Event()
@@ -97,15 +97,10 @@ class SpectatorClient(
val envelope = SpectatorProtocol.decode(read.text) ?: continue
val message = envelope.message
if (!joined) {
// reject keeps its shape across versions, so read it before the version gate.
if (message is SpectatorMessage.Reject) {
emit(Event.JoinFailed(failureOf(message)))
return
}
if (envelope.version < minVersion) {
emit(Event.JoinFailed(Failure.UPDATE_HOST_APP))
return
}
if (message is SpectatorMessage.Welcome) {
joined = true
emit(Event.Joined(message))
@@ -133,8 +128,6 @@ class SpectatorClient(
private fun failureOf(reject: SpectatorMessage.Reject): Failure = when (reject.reason) {
RejectReason.FULL -> Failure.FULL
RejectReason.NO_GAME -> Failure.NO_GAME
RejectReason.UPDATE_REQUIRED ->
if (version < reject.minVersion) Failure.UPDATE_THIS_APP else Failure.UPDATE_HOST_APP
RejectReason.OTHER -> Failure.UNREACHABLE
}
@@ -141,14 +141,7 @@ class SpectatorHub(
val envelope = (first as? LineResult.Line)?.let { SpectatorProtocol.decode(it.text) }
when (envelope?.message) {
SpectatorMessage.StatusQuery -> reply(client, status())
is SpectatorMessage.Hello -> {
if (envelope.version < SpectatorProtocol.MIN_COMPATIBLE_VERSION) {
log("Spectator with protocol ${envelope.version} told to update")
reply(client, SpectatorMessage.Reject(RejectReason.UPDATE_REQUIRED, SpectatorProtocol.MIN_COMPATIBLE_VERSION))
} else {
spectator = admit(client)
}
}
is SpectatorMessage.Hello -> { spectator = admit(client) }
else -> Unit
}
} catch (e: IOException) {
@@ -57,7 +57,6 @@ data class SpectatorSnapshot(
enum class RejectReason(val wire: String) {
FULL("full"),
UPDATE_REQUIRED("update"),
NO_GAME("no_game"),
OTHER("other");
@@ -94,11 +93,7 @@ data class SpectatorEnvelope(val version: Int, val message: SpectatorMessage?)
* the sender's protocol version in "sv". Unknown types are skipped, never fatal.
*/
object SpectatorProtocol {
/**
* Bump on incompatible changes and raise [MIN_COMPATIBLE_VERSION] to the oldest version still
* understood. hello, status and reject keep their shape so any two versions can still tell
* each other that an update is required.
*/
/** Sent with every message for information only; no version is ever refused. */
const val VERSION = 1
const val MIN_COMPATIBLE_VERSION = 1