joffrey-bion / krossbow

A Kotlin multiplatform coroutine-based STOMP client over websockets, with built-in conversions.
MIT License
200 stars 15 forks source link

Provide a sample project to demonstrate a runnable full stack Krossbow example #480

Open joffrey-bion opened 6 months ago

joffrey-bion commented 6 months ago

For beginners, the getting started guide might not be sufficient to see how all the pieces come together. It would be useful to provide a sample project that they can explore and play with.

In the meantime, the Seven Wonders game project, which uses Krossbow for its client, is the only real example we can show, but for a beginner it is likely overwhelming.

See initial discussion in https://github.com/joffrey-bion/krossbow/issues/479

Polve commented 5 months ago

I'm learning (or at least trying :D) copying snippets from the Seven Wonders client but for example I got an error on this line taken from https://github.com/joffrey-bion/seven-wonders/blob/main/sw-client/src/commonMain/kotlin/org/luxons/sevenwonders/client/SevenWondersClient.kt#L47:

suspend fun watchErrors(): Flow<ErrorDTO> = stompSession.subscribe("/user/queue/errors", ErrorDTO.serializer())

The compiler tells me:

exception: src/main/kotlin/Main.kt:55:72: error: type mismatch: inferred type is String but StompSubscribeHeaders was expected exception: suspend fun watchErrors(): Flow = stompSession.subscribe("/user/queue/errors", ErrorDTO.serializer()) exception: ^

Any hints?

Polve commented 5 months ago

Found the problem, my bad: the "subscribe" function is overloaded and hence must be imported. The problem is fixed adding this import:

import org.hildan.krossbow.stomp.conversions.kxserialization.subscribe

Sorry for the noise!

joffrey-bion commented 5 months ago

No problem for the noise, I'm happy you found your answer :)