fix not end callkit when registration failed due to network reason

This commit is contained in:
Danmei Chen 2021-06-29 18:17:31 +02:00
parent c613c76fd1
commit b3e0b0a60a
2 changed files with 15 additions and 1 deletions

View file

@ -445,10 +445,19 @@ import AVFoundation
func onRegistrationStateChanged(core: Core, proxyConfig: ProxyConfig, state: RegistrationState, message: String) {
if core.proxyConfigList.count == 1 && (state == .Failed || state == .Cleared){
// terminate callkit immediately when registration failed or cleared, supporting single proxy configuration
CallManager.instance().endCallkit = true
for call in CallManager.instance().providerDelegate.uuids {
let callId = CallManager.instance().providerDelegate.callInfos[call.value]?.callId
if (callId != nil) {
let call = CallManager.instance().lc?.getCallByCallid(callId: callId!)
if (call != nil) {
// sometimes (for example) due to network, registration failed, in this case, keep the call
continue
}
}
CallManager.instance().providerDelegate.endCall(uuid: call.value)
}
CallManager.instance().endCallkit = true
} else {
CallManager.instance().endCallkit = false
}

View file

@ -134,6 +134,11 @@ class ProviderDelegate: NSObject {
func endCall(uuid: UUID) {
provider.reportCall(with: uuid, endedAt: .init(), reason: .failed)
let callId = callInfos[uuid]?.callId
if (callId != nil) {
uuids.removeValue(forKey: callId!)
}
callInfos.removeValue(forKey: uuid)
}
func endCallNotExist(uuid: UUID, timeout: DispatchTime) {