diff --git a/R5ProTestbed.xcodeproj/project.pbxproj b/R5ProTestbed.xcodeproj/project.pbxproj index 04763ff..fef5282 100644 --- a/R5ProTestbed.xcodeproj/project.pbxproj +++ b/R5ProTestbed.xcodeproj/project.pbxproj @@ -616,7 +616,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -655,7 +655,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -676,7 +676,7 @@ "$(PROJECT_DIR)/R5ProTestbed", ); INFOPLIST_FILE = R5ProTestbed/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -703,7 +703,7 @@ "$(PROJECT_DIR)/R5ProTestbed", ); INFOPLIST_FILE = R5ProTestbed/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/R5ProTestbed/Tests/SubscribeReconnect/SubscribeAutoReconnectTest.swift b/R5ProTestbed/Tests/SubscribeReconnect/SubscribeAutoReconnectTest.swift index c04cacf..3fed946 100644 --- a/R5ProTestbed/Tests/SubscribeReconnect/SubscribeAutoReconnectTest.swift +++ b/R5ProTestbed/Tests/SubscribeReconnect/SubscribeAutoReconnectTest.swift @@ -36,14 +36,22 @@ import R5Streaming class SubscribeAutoReconnectTest: BaseTest { var finished = false + var retryTimer: Timer? + static let RETRY_TIMEOUT: Float = 2.0 override func viewWillDisappear(_ animated: Bool) { self.finished = true + if (self.retryTimer != nil) { + self.retryTimer?.invalidate() + } super.viewWillDisappear(animated) } override func viewDidLoad() { self.finished = false + if (self.retryTimer != nil) { + self.retryTimer?.invalidate() + } super.viewDidLoad() // Do any additional setup after loading the view. @@ -79,18 +87,22 @@ class SubscribeAutoReconnectTest: BaseTest { super.onR5StreamStatus(stream, withStatus: statusCode, withMessage: msg) if(statusCode == Int32(r5_status_connection_error.rawValue) || - statusCode == Int32(r5_status_connection_close.rawValue)) { + statusCode == Int32(r5_status_connection_close.rawValue) || + statusCode == Int32(r5_status_disconnected.rawValue)) { //we can assume it failed here! NSLog("Connection error") - - DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) { - if self.finished { - return + if let timer = self.retryTimer { + timer.invalidate() + } + self.retryTimer = Timer.scheduledTimer(withTimeInterval: TimeInterval(SubscribeAutoReconnectTest.RETRY_TIMEOUT), repeats: false) { [weak self] timer in + + if (self != nil && !self!.finished) { + NSLog("Subscribing again!!") + self!.Subscribe() } - NSLog("Subscribing again!!") - self.Subscribe() + } } @@ -100,16 +112,22 @@ class SubscribeAutoReconnectTest: BaseTest { let view = currentView DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) { if(self.subscribeStream != nil) { - view?.attach(nil) +// view?.attach(nil) self.subscribeStream!.stop() self.subscribeStream = nil } - if self.finished { - return + if let timer = self.retryTimer { + timer.invalidate() + } + self.retryTimer = Timer.scheduledTimer(withTimeInterval: TimeInterval(SubscribeAutoReconnectTest.RETRY_TIMEOUT), repeats: false) { [weak self] timer in + + if (self != nil && !self!.finished) { + NSLog("Subscribing again!!") + self!.Subscribe() + } + } - NSLog("Subscribing again!!") - self.Subscribe() } }