Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Sources/ElevenLabs/Networking/ConnectionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ class ConnectionManager {
}
}

func room(_: Room, participant _: RemoteParticipant, didSubscribeToTrack publication: RemoteTrackPublication) {
func room(_: Room, participant _: RemoteParticipant, didPublishTrack publication: RemoteTrackPublication) {
print("[ConnectionManager] Agent audio track subscribed, checking readiness... \(publication.kind) \(agentConnected) \(agentTrackSubscribed)")
// Only trigger for agent audio tracks
if publication.kind == .audio, agentConnected, !agentTrackSubscribed {
if publication.kind == .audio, agentConnected {
agentTrackSubscribed = true
print("[ConnectionManager] Agent audio track subscribed, checking readiness...")
checkAgentReady()
Expand All @@ -137,10 +138,11 @@ class ConnectionManager {
timeoutTask = Task {
try? await Task.sleep(nanoseconds: UInt64(timeoutDuration * 1_000_000_000))
if !Task.isCancelled && agentConnected && !agentTrackSubscribed {
print("[ConnectionManager] Timeout waiting for agent track, proceeding anyway")
// Proceed even without track subscription to prevent indefinite waiting
agentTrackSubscribed = true
checkAgentReady()
print("[ConnectionManager] Timeout waiting for agent track - connection failed")
// Reset state and trigger disconnection
agentConnected = false
agentTrackSubscribed = false
onDisconnected()
}
}
}
Expand Down
Loading