broadcastFlow

abstract fun broadcastFlow(event: String): Flow<RealtimeBroadcast>(source)

Broadcasts can be messages sent by other clients within the same channel under a specific event.

Example:

val messageFlow = channel.broadcastFlow("message")
messageFlow.collect {
when(it) {
is BroadcastPayload.Json -> println("Received message: ${it.value}")
is BroadcastPayload.Binary -> println("Received binary payload")
}
}

Parameters

event

When a message is sent by another client, it will be sent under a specific event. This is the event that you want to listen to