https://kotlinlang.org logo
#coroutines
Title
# coroutines
n

Nate Emmons

04/12/2021, 2:27 AM
(Please redirect me if this should be in #getting-started). I'm jumping in way over my head and trying to do a multiplayer game server for my first Kotlin project. I'm trying to use Ktor Websockets for client-server communication. It's my understanding that i can run the 'core game loop' as a separate coroutine and then communicate with the client websocket coroutines via channels, am i going in the right direction? My game loop does not need to be very fast at all so i'm assuming i can comfortably
delay
back to the client websocket coroutines relatively frequently to look for new input
b

Big Chungus

04/12/2021, 8:26 AM
You can use channels (hot) ir flows (cold) for that
I'd run your main game loop on Dispatchers.Main and collect from a channel when needed that's produced by some pool of background coroutines on Dispatchers.Default
n

Nate Emmons

04/12/2021, 3:00 PM
Thanks for the advice, I'll take a look into that
3 Views