From e48dc809a95a3ac813c4da8798c9e57cbb6a32b6 Mon Sep 17 00:00:00 2001 From: joffrey-bion Date: Wed, 17 Feb 2021 02:34:18 +0100 Subject: Use automatic sayReady call to synchronize STOMP subscriptions before first turn We currently miss the preparedCard event from bots if they are too fast, because the server sends the first turn to everyone without knowing if all clients have properly subscribed to events. We now use sayReady to indicate to the server that all subscriptions have been made. --- .../src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sw-bot/src') diff --git a/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt b/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt index 6a4a5bf6..a0688f20 100644 --- a/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt +++ b/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt @@ -82,7 +82,10 @@ class SevenWondersBot( session.watchTurns().filter { it.action == Action.WATCH_SCORE }.first() } session.watchTurns() - .onStart { emit(currentTurn) } + .onStart { + session.sayReady() + emit(currentTurn) + } .takeWhile { it.action != Action.WATCH_SCORE } .catch { e -> logger.error("BOT $player: error in turnInfo flow", e) } .collect { turn -> -- cgit