stale-microphone-76591
12/30/2025, 8:38 AMpublishData(). Below is the function we’re using:
suspend fun sendText(text: String, topic: String = "lk.chat"): Boolean {
Log.d("LiveKitManager", "canPublishData=" + room?.localParticipant?.permissions?.canPublishData)
return try {
val payload = text.toByteArray(Charsets.UTF_8)
val res = room?.localParticipant?.publishData(
data = payload,
reliability = DataPublishReliability.RELIABLE,
topic = "chat"
)
Log.d("LiveKitManager","The res is $res")
res?.onFailure { Log.e("LiveKitManager", "publishData failed", it) }
res?.isSuccess == true
} catch (e: Exception) {
false
}
}
Observations
1. canPublishData is true for the local participant.
publishData() returns a success result (no exception thrown).
However, the data is not received on the remote participant side.
The topic parameter passed to the function ("lk.chat") seems to be ignored, and the SDK examples/documentation often show "lk.chat" as a default topic.
1. Changing the topic value (e.g., "chat", "custom") does not appear to affect delivery behavior.
Environment
• Platform: Android
• LiveKit Android SDK (latest stable)
• Room is successfully connected
• Permissions verified on server side
Would mean a lot if someone can guide us along in this.lively-winter-88668
01/02/2026, 12:00 PMtodo (probably because it predates the introduction of sendText in the SDK).
Here are code snippets for sending / receiving text in Android:
Receiving
LaunchedEffect(room) {
Timber.d { "Registering text stream handler for topic: $CHAT_TOPIC" }
room.registerTextStreamHandler(
topic = CHAT_TOPIC,
handler = { receiver, identity: Participant.Identity ->
Timber.d { "Text stream received from: ${identity.value}" }
coroutineScope.launch {
try {
val message = receiver.readAll().joinToString(separator = "")
Timber.d { "Message content: $message" }
Toast.makeText(
this@CallActivity,
"${identity.value}: $message",
Toast.LENGTH_SHORT
).show()
} catch (e: Exception) {
Timber.e(e) { "Error reading message" }
}
}
}
)
Timber.d { "Text stream handler registered successfully" }
}
Sending:
if (showMessageDialog) {
SendMessageDialog(
onDismissRequest = { showMessageDialog = false },
onSendMessage = { message ->
showMessageDialog = false
Timber.d { "Sending message: $message to topic: $CHAT_TOPIC" }
coroutineScope.launch {
try {
val result = room.localParticipant.sendText(
message,
StreamTextOptions(topic = CHAT_TOPIC)
)
result.onSuccess { info ->
Timber.d { "Message sent successfully, stream id: ${info.id}" }
}
result.onFailure { error ->
Timber.e(error) { "Failed to send message" }
}
} catch (e: Exception) {
Timber.e(e) { "Exception while sending message" }
}
}
},
)
}
This was the result of asking AI to implement the todo in the previously mentioned repo, but it seems to have done a good jobstale-microphone-76591
01/02/2026, 1:15 PM