Промежуточный коммит со звонками

This commit is contained in:
2026-03-26 00:31:35 +05:00
parent bc7efbfbd9
commit 3fffbd0392
2 changed files with 31 additions and 134 deletions

View File

@@ -234,7 +234,12 @@ object CallManager {
}
fun endCall() {
breadcrumb("UI: endCall requested")
val callerTrace =
Throwable()
.stackTrace
.take(6)
.joinToString(" | ") { "${it.className}.${it.methodName}:${it.lineNumber}" }
breadcrumb("UI: endCall requested by $callerTrace")
resetSession(reason = null, notifyPeer = true)
}
@@ -605,29 +610,30 @@ object CallManager {
onCallConnected()
}
PeerConnection.PeerConnectionState.FAILED,
PeerConnection.PeerConnectionState.CLOSED -> {
disconnectResetJob?.cancel()
disconnectResetJob = null
// Dispatch to our scope — this callback fires on WebRTC thread
scope.launch {
resetSession(reason = "Connection lost", notifyPeer = false)
}
}
PeerConnection.PeerConnectionState.CLOSED,
PeerConnection.PeerConnectionState.DISCONNECTED -> {
// Desktop tolerates short network dips; do not kill call immediately.
// Desktop flow is signal-driven. Keep call alive across short
// transport glitches and only fallback-reset after timeout.
disconnectResetJob?.cancel()
disconnectResetJob =
scope.launch {
delay(5_000L)
val timeoutMs =
when (newState) {
PeerConnection.PeerConnectionState.DISCONNECTED -> 15_000L
PeerConnection.PeerConnectionState.FAILED -> 12_000L
PeerConnection.PeerConnectionState.CLOSED -> 12_000L
else -> 12_000L
}
delay(timeoutMs)
val pcState = peerConnection?.connectionState()
if (pcState == PeerConnection.PeerConnectionState.DISCONNECTED ||
pcState == PeerConnection.PeerConnectionState.FAILED ||
pcState == PeerConnection.PeerConnectionState.CLOSED
) {
breadcrumb("PC: DISCONNECTED timeout → reset")
breadcrumb("PC: $newState timeout ($timeoutMs ms) → reset")
resetSession(reason = "Connection lost", notifyPeer = false)
} else {
breadcrumb("PC: DISCONNECTED recovered (state=$pcState)")
breadcrumb("PC: $newState recovered (state=$pcState)")
}
}
}