summaryrefslogtreecommitdiff
path: root/sw-client/src/commonMain/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'sw-client/src/commonMain/kotlin')
-rw-r--r--sw-client/src/commonMain/kotlin/org/luxons/sevenwonders/client/SevenWondersClient.kt23
1 files changed, 14 insertions, 9 deletions
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 3a3cb989..50b9b70c 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
@@ -42,16 +42,21 @@ class SevenWondersSession(private val stompSession: StompSessionWithKxSerializat
suspend fun watchErrors(): Flow<ErrorDTO> = stompSession.subscribe("/user/queue/errors", ErrorDTO.serializer())
suspend fun chooseName(displayName: String, icon: Icon? = null, isHuman: Boolean = true): ConnectedPlayer {
- val sub = stompSession.subscribe(
- destination = "/user/queue/nameChoice",
- deserializer = ConnectedPlayer.serializer(),
+ return doAndWaitForEvent(
+ send = {
+ stompSession.convertAndSend(
+ destination = "/app/chooseName",
+ body = ChooseNameAction(displayName, icon, isHuman),
+ serializer = ChooseNameAction.serializer(),
+ )
+ },
+ subscribe = {
+ stompSession.subscribe(
+ destination = "/user/queue/nameChoice",
+ deserializer = ConnectedPlayer.serializer(),
+ )
+ }
)
- stompSession.convertAndSend(
- destination = "/app/chooseName",
- body = ChooseNameAction(displayName, icon, isHuman),
- serializer = ChooseNameAction.serializer(),
- )
- return sub.first()
}
suspend fun watchGames(): Flow<GameListEvent> =
bgstack15