Integrate live phone and watch remote prototype with guarded motion control
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import SwiftUI
|
||||
import PhoneControl
|
||||
import SecureStorage
|
||||
import TVTransport
|
||||
import WatchBridgeCommon
|
||||
import WatchBridgePhone
|
||||
import WatchConnectivity
|
||||
|
||||
@MainActor
|
||||
final class PhoneAppComposition: ObservableObject {
|
||||
let controller: LivePhoneController
|
||||
private let relay: PhoneWCSessionDelegate?
|
||||
|
||||
init() {
|
||||
let authorization = KeychainTVAuthorizationStore()
|
||||
let certificateReceiver = CertificateReceiver()
|
||||
let factory = URLSessionSamsungSocketFactory(onUntrustedCertificate: { host, fingerprint in
|
||||
Task { @MainActor in certificateReceiver.controller?.receiveUntrustedCertificate(host: host, sha256: fingerprint) }
|
||||
})
|
||||
let transport = TVConnectionActor(socketFactory: factory, authorizationStore: authorization)
|
||||
controller = LivePhoneController(transport: transport, authorization: authorization,
|
||||
selection: KeychainSelectedTelevisionStore())
|
||||
certificateReceiver.controller = controller
|
||||
if WCSession.isSupported() {
|
||||
let relay = PhoneWCSessionDelegate(coordinator: transport)
|
||||
self.relay = relay
|
||||
controller.onSelectionChanged = { [weak relay] television, ready in
|
||||
relay?.bridge.publishContext(.init(selectedTelevisionID: television?.id,
|
||||
displayName: television?.name, isConnectionReady: ready))
|
||||
}
|
||||
} else { relay = nil }
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private final class CertificateReceiver {
|
||||
weak var controller: LivePhoneController?
|
||||
}
|
||||
Reference in New Issue
Block a user