diff options
author | joffrey-bion <joffrey.bion@gmail.com> | 2021-02-17 02:34:18 +0100 |
---|---|---|
committer | joffrey-bion <joffrey.bion@gmail.com> | 2021-02-17 02:34:18 +0100 |
commit | e48dc809a95a3ac813c4da8798c9e57cbb6a32b6 (patch) | |
tree | aa5219552150be13cb0d2fcbc340313260ba928d /sw-bot/src/main/kotlin/org | |
parent | Add prepared card indicator (diff) | |
download | seven-wonders-e48dc809a95a3ac813c4da8798c9e57cbb6a32b6.tar.gz seven-wonders-e48dc809a95a3ac813c4da8798c9e57cbb6a32b6.tar.bz2 seven-wonders-e48dc809a95a3ac813c4da8798c9e57cbb6a32b6.zip |
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.
Diffstat (limited to 'sw-bot/src/main/kotlin/org')
-rw-r--r-- | sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt | 5 |
1 files changed, 4 insertions, 1 deletions
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 -> |