Skip to content

Commit

Permalink
Cleanup of Bonjour discovery
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Bert <[email protected]>
  • Loading branch information
timbms committed Jan 15, 2024
1 parent 22b9aad commit fdb026f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
1 change: 0 additions & 1 deletion openHAB/WatchMessageService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 5 additions & 8 deletions openHABWatch/Domain/OpenHABWatchTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand All @@ -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)
}
Expand Down
9 changes: 0 additions & 9 deletions openHABWatch/Domain/UserData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit fdb026f

Please sign in to comment.