From e600544531764f67a5917483526d8d1941454640 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Thu, 26 Mar 2020 20:50:25 +0100 Subject: Rework sagas and router to sub/unsubscribe properly --- .../kotlin/org/luxons/sevenwonders/client/SevenWondersClient.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sw-client/src/commonMain') diff --git a/sw-client/src/commonMain/kotlin/org/luxons/sevenwonders/client/SevenWondersClient.kt b/sw-client/src/commonMain/kotlin/org/luxons/sevenwonders/client/SevenWondersClient.kt index 4acbccd9..c4293c2a 100644 --- a/sw-client/src/commonMain/kotlin/org/luxons/sevenwonders/client/SevenWondersClient.kt +++ b/sw-client/src/commonMain/kotlin/org/luxons/sevenwonders/client/SevenWondersClient.kt @@ -88,8 +88,11 @@ class SevenWondersSession(private val stompSession: StompSessionWithKxSerializat suspend fun watchLobbyUpdates(gameId: Long): StompSubscription = stompSession.subscribe("/topic/lobby/$gameId/updated", LobbyDTO.serializer()) - suspend fun watchGameStart(gameId: Long): StompSubscription = - stompSession.subscribeEmptyMsg("/topic/lobby/$gameId/started") + suspend fun awaitGameStart(gameId: Long) { + val gameStartSubscription = stompSession.subscribeEmptyMsg("/topic/lobby/$gameId/started") + gameStartSubscription.messages.receive() + gameStartSubscription.unsubscribe() + } suspend fun startGame() { stompSession.sendEmptyMsg("/app/lobby/startGame") -- cgit