|
@@ -8,6 +8,7 @@
|
|
|
|
|
|
import Foundation
|
|
import Foundation
|
|
import nuSDKService
|
|
import nuSDKService
|
|
|
|
+import Network
|
|
|
|
|
|
class Callback : CallBack {
|
|
class Callback : CallBack {
|
|
var sID: String = "Callback"
|
|
var sID: String = "Callback"
|
|
@@ -20,6 +21,7 @@ class Callback : CallBack {
|
|
if let delegate = Nexilis.shared.connectionDelegate {
|
|
if let delegate = Nexilis.shared.connectionDelegate {
|
|
delegate.connectionStateChanged(userId: sUserID, deviceId: sDeviceID, state: bConState)
|
|
delegate.connectionStateChanged(userId: sUserID, deviceId: sDeviceID, state: bConState)
|
|
}
|
|
}
|
|
|
|
+ InquiryThread.default.set(wait: nCLMConStat == 0)
|
|
OutgoingThread.default.set(wait: nCLMConStat == 0)
|
|
OutgoingThread.default.set(wait: nCLMConStat == 0)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -130,3 +132,32 @@ class Callback : CallBack {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+class NetworkMonitor {
|
|
|
|
+ static let shared = NetworkMonitor()
|
|
|
|
+
|
|
|
|
+ private let monitor = NWPathMonitor()
|
|
|
|
+ private var isMonitoring = false
|
|
|
|
+
|
|
|
|
+ private init() {}
|
|
|
|
+
|
|
|
|
+ func startMonitoring() {
|
|
|
|
+ guard !isMonitoring else { return }
|
|
|
|
+
|
|
|
|
+ monitor.pathUpdateHandler = { path in
|
|
|
|
+ //print("CONNECTION \(path.status == .satisfied)")
|
|
|
|
+ InquiryThread.default.set(wait: !(path.status == .satisfied))
|
|
|
|
+ OutgoingThread.default.set(wait: !(path.status == .satisfied))
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let queue = DispatchQueue(label: "NetworkMonitor")
|
|
|
|
+ monitor.start(queue: queue)
|
|
|
|
+ isMonitoring = true
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func stopMonitoring() {
|
|
|
|
+ guard isMonitoring else { return }
|
|
|
|
+ monitor.cancel()
|
|
|
|
+ isMonitoring = false
|
|
|
|
+ }
|
|
|
|
+}
|