summaryrefslogtreecommitdiff
path: root/Example Apps/Example Swift/ProxyManager.swift
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2019-04-23 10:42:55 -0400
committerJoel Fischer <joeljfischer@gmail.com>2019-04-23 10:42:55 -0400
commitf2f33e8a9c65914fdf5ee683918ab0f3590dc29d (patch)
treefb10d90e910d8c90f106c86880d89829e5fe8099 /Example Apps/Example Swift/ProxyManager.swift
parent02ade0d7ad88d217e1088204add6c041e6e87114 (diff)
downloadsdl_ios-bugfix/issue_1243_swift_example_autoreconnect.tar.gz
Diffstat (limited to 'Example Apps/Example Swift/ProxyManager.swift')
-rw-r--r--Example Apps/Example Swift/ProxyManager.swift16
1 files changed, 12 insertions, 4 deletions
diff --git a/Example Apps/Example Swift/ProxyManager.swift b/Example Apps/Example Swift/ProxyManager.swift
index ba199b543..fbedae0d5 100644
--- a/Example Apps/Example Swift/ProxyManager.swift
+++ b/Example Apps/Example Swift/ProxyManager.swift
@@ -49,9 +49,14 @@ extension ProxyManager {
}
/// Attempts to close the connection between the this app and the car's head unit. The `SDLManagerDelegate`'s `managerDidDisconnect()` is called when connection is actually closed.
- func resetConnection() {
+ func stopConnection() {
+ guard sdlManager != nil else {
+ delegate?.didChangeProxyState(.stopped)
+ return
+ }
+
sdlManager.stop()
- delegate?.didChangeProxyState(ProxyState.stopped)
+ delegate?.didChangeProxyState(.stopped)
}
}
@@ -115,7 +120,7 @@ private extension ProxyManager {
sdlManager.start(readyHandler: { [unowned self] (success, error) in
guard success else {
SDLLog.e("There was an error while starting up: \(String(describing: error))")
- self.resetConnection()
+ self.stopConnection()
return
}
@@ -137,7 +142,10 @@ private extension ProxyManager {
extension ProxyManager: SDLManagerDelegate {
/// Called when the connection beween this app and SDL Core has closed.
func managerDidDisconnect() {
- delegate?.didChangeProxyState(ProxyState.searching)
+ if delegate?.proxyState != .some(.stopped) {
+ delegate?.didChangeProxyState(ProxyState.searching)
+ }
+
firstHMILevelState = .none
}