Hey guys, I still don't really understand how to "...
# kotlinx-rpc
t
Hey guys, I still don't really understand how to "properly" do server -> client communication. My current solution uses flows, but I wish to simplify it since my client represents many users at once, and each user needs to register onto a "queue" (
MutableSharedFlow
) of events which need to be listened to in real-time that I can emit from the server-side. Is there no direct way to do a server -> client call? Or at least something simpler than with mutable flow?
a
Flows are the way to go. Client subscribes to the flow of updates from the server. No mutable flow required. Or did I miss something?
t
If no mutable flow is required, then how can I emit a message outside a call?
Copy code
@Rpc
interface EventService : RemoteService {
    suspend fun subscribe(uuid: Long): SharedFlow<Event>
}
as in, subscribe a UUID, and down the road later on the server emit an event to that flow and have the client handle it