Skip to content

Commit

Permalink
Send client ready message
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-daily committed Aug 19, 2024
1 parent 1e530e7 commit a535376
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import android.util.Log
import co.daily.CallClient
import co.daily.CallClientListener
import co.daily.model.CallState
import co.daily.model.MediaState
import co.daily.model.MeetingToken
import co.daily.model.ParticipantLeftReason
import co.daily.model.Recipient
Expand Down Expand Up @@ -64,6 +65,7 @@ class DailyTransport(

val participants = mutableMapOf<ParticipantId, Participant>()
var botUser: Participant? = null
var clientReady: Boolean = false

override fun onLocalAudioLevel(audioLevel: Float) {
transportContext.callbacks.onUserAudioLevel(audioLevel)
Expand Down Expand Up @@ -100,6 +102,19 @@ class DailyTransport(
override fun onParticipantUpdated(participant: co.daily.model.Participant) {
updateParticipant(participant)
updateBotUser()

if (!clientReady && participant.id.toRtvi() == botUser?.id) {
if (participant.media?.microphone?.state == MediaState.playable) {

Log.i(TAG, "Sending client-ready")

clientReady = true
sendMessage(MsgClientToServer(
type = "client-ready",
data = null
))
}
}
}

private fun updateBotUser() {
Expand All @@ -122,6 +137,7 @@ class DailyTransport(
CallState.leaving -> {}
CallState.left -> {
botUser = null
clientReady = false
participants.clear()
setState(TransportState.Disconnected)
transportContext.callbacks.onDisconnected()
Expand Down

0 comments on commit a535376

Please sign in to comment.