Explorar el Código

update add callfcm (not ready)

alqindiirsyam hace 1 año
padre
commit
9eeb00fd0d

+ 31 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/CoreMessage_TMessageBank.swift

@@ -2405,4 +2405,35 @@ public class CoreMessage_TMessageBank {
         return tmessage
     }
     
+    public static func getCalling(fPin: String, type: String) -> TMessage {
+        let tmessage = TMessage()
+        tmessage.mCode = CoreMessage_TMessageCode.CALLING
+        tmessage.mStatus = CoreMessage_TMessageUtil.getTID()
+        tmessage.mPIN = User.getMyPin() ?? ""
+        tmessage.mBodies[CoreMessage_TMessageKey.F_PIN] = fPin
+        tmessage.mBodies[CoreMessage_TMessageKey.TYPE] = type
+        return tmessage
+    }
+
+    public static func getNotifyCalling(fPin: String, lPin: String, type: String) -> TMessage {
+        let tmessage = TMessage()
+        tmessage.mCode = CoreMessage_TMessageCode.NOTIFY_TO_CALLING
+        tmessage.mStatus = CoreMessage_TMessageUtil.getTID()
+        tmessage.mPIN = User.getMyPin() ?? ""
+        tmessage.mBodies[CoreMessage_TMessageKey.F_PIN] = fPin
+        tmessage.mBodies[CoreMessage_TMessageKey.TYPE] = type
+        tmessage.mBodies[CoreMessage_TMessageKey.L_PIN] = lPin
+        return tmessage
+    }
+
+    public static func getCancelCall(fPin: String, type: String) -> TMessage {
+        let tmessage = TMessage()
+        tmessage.mCode = CoreMessage_TMessageCode.CANCEL_CALL_NOTIFICATION
+        tmessage.mStatus = CoreMessage_TMessageUtil.getTID()
+        tmessage.mPIN = User.getMyPin() ?? ""
+        tmessage.mBodies[CoreMessage_TMessageKey.F_PIN] = fPin
+        tmessage.mBodies[CoreMessage_TMessageKey.TYPE] = type
+        return tmessage
+    }
+    
 }

+ 4 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/CoreMessage_TMessageCode.swift

@@ -763,4 +763,8 @@ public class CoreMessage_TMessageCode {
     public static let SS_END = 128;
     
     public static let GET_BATCH_GROUP_NO_MEMBERS = "GGNM";
+    
+    public static let CALLING = "CALL";
+    public static let NOTIFY_TO_CALLING = "NTC";
+    public static let CANCEL_CALL_NOTIFICATION = "CCN";
 }

+ 23 - 1
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Call/QmeraAudioViewController.swift

@@ -20,6 +20,7 @@ class QmeraAudioViewController: UIViewController {
     var wbTimer = Timer()
     var wbBlink = false
     var wbRoomId = ""
+    var callFCM = false
     
     let buttonSize: CGFloat = 70
     
@@ -278,8 +279,29 @@ class QmeraAudioViewController: UIViewController {
 //                if onGoingCC.isEmpty {
 //                    Nexilis.shared.callManager.startCall(handle: u.pin)
 //                } else {
-                    API.initiateCCall(sParty: u.pin)
+//                    API.initiateCCall(sParty: u.pin)
 //                }
+                if callFCM {
+                    DispatchQueue.global().async {
+                        if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getCalling(fPin: u.pin, type: "1"), timeout: 30 * 1000) {
+                            if response.isOk() {
+                                
+                            } else {
+                                DispatchQueue.main.async {
+                                    self.status.text = "Busy"
+                                    self.end.isEnabled = false
+                                }
+                            }
+                        } else {
+                            let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                            imageView.tintColor = .white
+                            let banner = FloatingNotificationBanner(title: "Unable to access servers. Try again later".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+                            banner.show()
+                        }
+                    }
+                } else {
+                    API.initiateCCall(sParty: u.pin)
+                }
             } else if !ticketId.isEmpty {
                 if isOutgoing {
                     API.ccs(sTicketID: ticketId, nCamIdx: 1, nResIdx: 2, nVQuality: 4, ivRemoteView: listRemoteViewFix, ivLocalView: cameraView, ivRemoteZ: zoomView, bCameraOn: false)

+ 22 - 1
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Call/QmeraVideoViewController.swift

@@ -22,6 +22,7 @@ class QmeraVideoViewController: UIViewController {
     var isInisiator = true
     var isSpeaker = true
     var isPresent = false
+    var callFCM = false
     var listRemoteViewFix: [UIImageView] = [
         UIImageView(),
         UIImageView(),
@@ -372,7 +373,27 @@ class QmeraVideoViewController: UIViewController {
             labelIncomingOutgoing.text = "Outgoing video call".localized() + "..."
 //            Nexilis.startAudio()
             if ticketId.isEmpty {
-                API.initiateCCall(sParty: dataPerson[0]["f_pin"]!, nCamIdx: 1, nResIdx: 2, nVQuality: 4, ivRemoteView: listRemoteViewFix, ivLocalView: cameraView, ivRemoteZ: zoomView)
+                if callFCM {
+                    DispatchQueue.global().async {
+                        if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getCalling(fPin: u.pin, type: "1"), timeout: 30 * 1000) {
+                            if response.isOk() {
+                                
+                            } else {
+                                DispatchQueue.main.async {
+                                    self.status.text = "Busy"
+                                    self.end.isEnabled = false
+                                }
+                            }
+                        } else {
+                            let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                            imageView.tintColor = .white
+                            let banner = FloatingNotificationBanner(title: "Unable to access servers. Try again later".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+                            banner.show()
+                        }
+                    }
+                } else {
+                    API.initiateCCall(sParty: dataPerson[0]["f_pin"]!, nCamIdx: 1, nResIdx: 2, nVQuality: 4, ivRemoteView: listRemoteViewFix, ivLocalView: cameraView, ivRemoteZ: zoomView)
+                }
             } else {
                 API.ccs(sTicketID: ticketId, nCamIdx: 1, nResIdx: 2, nVQuality: 4, ivRemoteView: listRemoteViewFix, ivLocalView: cameraView, ivRemoteZ: zoomView, bCameraOn: true)
                 if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getIncomingCallCS(f_pin_opposite: users[0].pin), timeout: 30 * 1000){