From 24e23aaf5979e8829f0635d6b325a5fbdd24c213 Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Tue, 4 Aug 2020 17:37:43 +0200 Subject: [PATCH] Update login tutorial to use delegates rather than hard-coded flag --- swift/LoginTutorial/LoginTutorial/LoginExample.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/swift/LoginTutorial/LoginTutorial/LoginExample.swift b/swift/LoginTutorial/LoginTutorial/LoginExample.swift index 9018191..c9ad37e 100644 --- a/swift/LoginTutorial/LoginTutorial/LoginExample.swift +++ b/swift/LoginTutorial/LoginTutorial/LoginExample.swift @@ -27,6 +27,7 @@ class LoginTutorialContext : ObservableObject init() { + mRegistrationDelegate.tutorialContext = self let factory = Factory.Instance // Instanciate logManager = LinphoneLoggingServiceManager() @@ -66,7 +67,6 @@ class LoginTutorialContext : ObservableObject // IMPORTANT : default proxy config setting MUST be done AFTER adding the config to the core ! mCore.defaultProxyConfig = proxy_cfg } - loggedIn = true } catch { print(error) @@ -88,7 +88,14 @@ class LinphoneLoggingServiceManager: LoggingServiceDelegate { } class LinphoneRegistrationDelegate: CoreDelegate { + + var tutorialContext : LoginTutorialContext! + override func onRegistrationStateChanged(lc: Core, cfg: ProxyConfig, cstate: RegistrationState, message: String?) { print("New registration state \(cstate) for user id \( String(describing: cfg.identityAddress?.asString()))\n") + if (cstate == .Ok) + { + tutorialContext.loggedIn = true + } } }