|
|
|
@ -17,7 +17,12 @@ extension AppDelegate {
|
|
|
|
|
conversationVC.inputAccessoryView?.alpha = 0
|
|
|
|
|
}
|
|
|
|
|
presentingVC.present(callVC, animated: true, completion: nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func dismissAllCallUI() {
|
|
|
|
|
if let currentBanner = IncomingCallBanner.current { currentBanner.dismiss() }
|
|
|
|
|
if let callVC = CurrentAppContext().frontmostViewController() as? CallVC { callVC.handleEndCallMessage() }
|
|
|
|
|
if let miniCallView = MiniCallView.current { miniCallView.dismiss() }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func setUpCallHandling() {
|
|
|
|
@ -72,6 +77,10 @@ extension AppDelegate {
|
|
|
|
|
MessageReceiver.handleAnswerCallMessage = { message in
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
|
guard let call = AppEnvironment.shared.callManager.currentCall, message.uuid! == call.uuid else { return }
|
|
|
|
|
if message.sender! == getUserHexEncodedPublicKey() {
|
|
|
|
|
self.dismissAllCallUI()
|
|
|
|
|
AppEnvironment.shared.callManager.reportCurrentCallEnded(reason: .answeredElsewhere)
|
|
|
|
|
} else {
|
|
|
|
|
AppEnvironment.shared.callManager.invalidateTimeoutTimer()
|
|
|
|
|
call.hasStartedConnecting = true
|
|
|
|
|
let sdp = RTCSessionDescription(type: .answer, sdp: message.sdps![0])
|
|
|
|
@ -80,16 +89,20 @@ extension AppDelegate {
|
|
|
|
|
callVC.handleAnswerMessage(message)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// End call messages
|
|
|
|
|
MessageReceiver.handleEndCallMessage = { message in
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
|
if let currentBanner = IncomingCallBanner.current { currentBanner.dismiss() }
|
|
|
|
|
if let callVC = CurrentAppContext().frontmostViewController() as? CallVC { callVC.handleEndCallMessage() }
|
|
|
|
|
if let miniCallView = MiniCallView.current { miniCallView.dismiss() }
|
|
|
|
|
guard let call = AppEnvironment.shared.callManager.currentCall, message.uuid! == call.uuid else { return }
|
|
|
|
|
self.dismissAllCallUI()
|
|
|
|
|
if message.sender! == getUserHexEncodedPublicKey() {
|
|
|
|
|
AppEnvironment.shared.callManager.reportCurrentCallEnded(reason: .declinedElsewhere)
|
|
|
|
|
} else {
|
|
|
|
|
AppEnvironment.shared.callManager.reportCurrentCallEnded(reason: .remoteEnded)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: Configuration message
|
|
|
|
|
@objc(syncConfigurationIfNeeded)
|
|
|
|
|