fix end call

This commit is contained in:
Danmei Chen 2020-04-17 09:32:19 +02:00
parent a0b7dd0dda
commit 7b4427e785
2 changed files with 11 additions and 5 deletions

View file

@ -176,7 +176,7 @@ import AVFoundation
if (uuid != nil) {
// This call was declined.
providerDelegate.reportIncomingCall(call:nil, uuid: uuid!, handle: "Calling", hasVideo: false)
providerDelegate.endCallNotExist(uuid: uuid!, timeout: .now())
providerDelegate.endCall(uuid: uuid!)
return
}
@ -378,7 +378,7 @@ import AVFoundation
providerDelegate.uuids.updateValue(uuid, forKey: callId)
} else {
// end call
providerDelegate.endCallNotExist(uuid: uuid!, timeout: .now())
providerDelegate.endCall(uuid: uuid!)
}
}
}

View file

@ -121,12 +121,18 @@ class ProviderDelegate: NSObject {
func reportOutgoingCallConnected(uuid:UUID) {
provider.reportOutgoingCall(with: uuid, connectedAt: nil)
}
func endCall(uuid: UUID) {
provider.reportCall(with: uuid, endedAt: .init(), reason: .declinedElsewhere)
}
func endCallNotExist(uuid: UUID, timeout: DispatchTime) {
DispatchQueue.main.asyncAfter(deadline: timeout) {
if (CallManager.instance().lc?.callsNb == 0) {
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: terminate call \(uuid) which does not exist.")
CallManager.instance().providerDelegate.provider.reportCall(with: uuid, endedAt: .init(), reason: .declinedElsewhere)
let callId = CallManager.instance().providerDelegate.callInfos[uuid]?.callId
let call = CallManager.instance().callByCallId(callId: callId)
if (call == nil) {
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: terminate call with call-id: \(String(describing: callId)) and UUID: \(uuid) which does not exist.")
CallManager.instance().providerDelegate.endCall(uuid: uuid)
}
}
}