update callcenter

This commit is contained in:
DDIsFriend
2023-09-05 14:51:24 +08:00
parent 1db91e1e14
commit 177b77c044
26 changed files with 8425 additions and 7824 deletions

View File

@@ -17,7 +17,7 @@ open class SystemCall {
private let callCenter : CTCallCenter
public var callSuccess : Bool
public var callSuccess : Bool = false
private var isDialing : Bool = false
@@ -27,6 +27,8 @@ open class SystemCall {
private var callTime : String?
private var dialingTimeInterval : TimeInterval?
private var connectTimeInterval : TimeInterval?
private var disconnectTimeInterval : TimeInterval?
@@ -43,7 +45,6 @@ open class SystemCall {
init() {
callCenter = CTCallCenter()
callSuccess = false
}
func callEvent(successHandler: ((Bool,String?,Int?) -> Void)? = nil) {
@@ -51,10 +52,16 @@ open class SystemCall {
switch call.callState {
case "CTCallStateDialing":
self?.isDialing = true
self?.isConnected = false
self?.isDisconnected = false
self?.callTime = TOOL.getDateString(by: "yyyy-MM-dd HH:mm:ss", date: Date())
self?.dialingTimeInterval = Date().timeIntervalSince1970
break
case "CTCallStateIncoming":
self?.isDialing = false
self?.isConnected = false
self?.isDisconnected = false
break
case "CTCallStateConnected":
self?.isConnected = true
@@ -68,8 +75,8 @@ open class SystemCall {
self?.callSuccess = true
if successHandler != nil {
var duration = 0
if let disconnectTimeInterval = self?.disconnectTimeInterval,let connectTimeInterval = self?.connectTimeInterval {
duration = Int(disconnectTimeInterval - connectTimeInterval)
if let disconnectTimeInterval = self?.disconnectTimeInterval,let dialingTimeInterval = self?.dialingTimeInterval {
duration = Int(disconnectTimeInterval - dialingTimeInterval)
self?.duration = duration
}
successHandler!(true,self?.callTime,duration)