From fdb026f6fd80bf611ea0ff17e63e7fdc68a65852 Mon Sep 17 00:00:00 2001 From: Tim Bert <5411131+timbms@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:15:16 +0100 Subject: [PATCH] Cleanup of Bonjour discovery Signed-off-by: Tim Bert <5411131+timbms@users.noreply.github.com> --- openHAB/WatchMessageService.swift | 1 - openHABWatch/Domain/OpenHABWatchTracker.swift | 13 +++++-------- openHABWatch/Domain/UserData.swift | 9 --------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/openHAB/WatchMessageService.swift b/openHAB/WatchMessageService.swift index bd24c135..86403909 100644 --- a/openHAB/WatchMessageService.swift +++ b/openHAB/WatchMessageService.swift @@ -21,7 +21,6 @@ class WatchMessageService: NSObject, WCSessionDelegate { // This method gets called when the watch requests the data func session(_ session: WCSession, didReceiveMessage message: [String: Any], replyHandler: @escaping ([String: Any]) -> Void) { - // TODO: Use RemoteUrl, TOO os_log("didReceiveMessage %{PUBLIC}@", log: .watch, type: .info, "\(message)") if message["request"] != nil { diff --git a/openHABWatch/Domain/OpenHABWatchTracker.swift b/openHABWatch/Domain/OpenHABWatchTracker.swift index 7fb4ba67..0e350c8c 100644 --- a/openHABWatch/Domain/OpenHABWatchTracker.swift +++ b/openHABWatch/Domain/OpenHABWatchTracker.swift @@ -140,12 +140,10 @@ class OpenHABWatchTracker: NSObject { } if components.host == nil { os_log("OpenHABWatchTracker unable to build URL from discovered endpoint, using remote URL instead", log: OSLog.remoteAccess, type: .info) -// TODO: -// self.trackedRemoteUrl() + self.tryUrl(URL(string: self.openHABRemoteUrl)) } else { os_log("OpenHABWatchTracker discovered: %{PUBLIC}@ ", log: OSLog.remoteAccess, type: .info, components.url?.description ?? "") -// TODO: -// self.trackedDiscoveryUrl(components.url) + self.tryUrl(components.url) } return default: @@ -158,8 +156,7 @@ class OpenHABWatchTracker: NSObject { // Error establishing the connection or other unknown condition connection.cancel() os_log("OpenHABWatchTracker unable establish connection to discovered endpoint, using remote URL instead", log: OSLog.remoteAccess, type: .info) -// TODO: -// self.trackedRemoteUrl() + self.tryUrl(URL(string: self.openHABRemoteUrl)) } } self.netBrowser!.cancel() @@ -173,8 +170,8 @@ class OpenHABWatchTracker: NSObject { // Unable to discover local endpoint os_log("OpenHABWatchTracker unable to discover local server, using remote URL", log: OSLog.remoteAccess, type: .info) -// TODO: -// self.trackedRemoteUrl() + self.tryUrl(URL(string: self.openHABRemoteUrl)) + } netBrowser?.start(queue: .main) } diff --git a/openHABWatch/Domain/UserData.swift b/openHABWatch/Domain/UserData.swift index bcd054ca..27e24ec8 100644 --- a/openHABWatch/Domain/UserData.swift +++ b/openHABWatch/Domain/UserData.swift @@ -77,15 +77,6 @@ final class UserData: ObservableObject { init(url: URL?) { tracker = OpenHABWatchTracker() tracker?.delegate = self -// TODO: -// tracker?.trackedUrl(url) - -// dataObjectCancellable = ObservableOpenHABDataObject.shared.objectRefreshed.sink { _ in -// // New settings updates from the phone app to start a reconnect -// os_log("Settings update received, starting reconnect", log: .remoteAccess, type: .info) -// self.refreshUrl() -// } -// refreshUrl() } init(sitemapName: String = "watch") {