RiValT_WatchDelegate

@MainActor
final class RiValT_WatchDelegate : NSObject
extension RiValT_WatchDelegate: WCSessionDelegate

The iPhone or iPad owns the timer. A Watch sends explicit, expiring commands against a state it has seen.

  • The timer and control sample exchanged with the Watch.

    Declaration

    Swift

    typealias Snapshot = RiValT_RemoteState.Snapshot
  • The phase displayed for the current timer sample.

    Declaration

    Swift

    typealias Phase = RiValT_RemoteState.Phase
  • Declaration

    Swift

    private extension RiValT_WatchDelegate.Phase
  • An explicit control action the Watch can request.

    Declaration

    Swift

    typealias TimerOperation = RiValT_RemoteState.TimerOperation
  • Declaration

    Swift

    private extension RiValT_WatchDelegate.TimerOperation
  • The shared WatchConnectivity session when supported by the device.

    Declaration

    Swift

    @MainActor
    private var session: WCSession? { get }
  • The Bluetooth link used for a nearby iPad.

    Declaration

    Swift

    @MainActor
    private let padLink: RiValT_BluetoothRemote
  • Notifies the Watch model when the snapshot, connection, or command status changes.

    Declaration

    Swift

    @MainActor
    var updateHandler: (() -> Void)?
  • Notifies the app when it can reconsider completing background connectivity work.

    Declaration

    Swift

    @MainActor
    var connectivityProgressHandler: (() -> Void)?
  • Tracks complication updates still waiting to be stored on the main actor.

    Declaration

    Swift

    private nonisolated let complicationDeliveries: DispatchGroup
  • The latest live host sample with its countdown deadline converted to Watch time.

    Declaration

    Swift

    @MainActor
    private(set) var snapshot: Snapshot? { get }
  • Whether the chosen host has provided a valid live sample on the current connection.

    Declaration

    Swift

    @MainActor
    private(set) var canReachHost: Bool { get }
  • Whether session activation or the latest state request failed.

    Declaration

    Swift

    @MainActor
    private(set) var connectionFailed: Bool { get }
  • Whether WatchConnectivity activation is waiting for its delegate callback.

    Declaration

    Swift

    @MainActor
    private var activatingSession: Bool
  • Whether the Watch is waiting for the first live sample or the phone session to activate.

    Declaration

    Swift

    @MainActor
    var isConnecting: Bool { get }
  • Whether a control command is waiting to be sent or acknowledged.

    Declaration

    Swift

    @MainActor
    private(set) var isUpdateInProgress: Bool { get }
  • Whether the last command was declined or its target state changed before it could be sent.

    Declaration

    Swift

    @MainActor
    private(set) var commandRejected: Bool { get }
  • Whether the Watch scene is active and should send interactive requests.

    Declaration

    Swift

    @MainActor
    private var active: Bool
  • The identifier of the single request currently in flight.

    Declaration

    Swift

    @MainActor
    private var pendingID: String?
  • A control intent kept with the host state the wearer saw while a poll was in flight.

    See more

    Declaration

    Swift

    private struct PendingCommand
  • The command to reconsider after the current poll completes.

    Declaration

    Swift

    @MainActor
    private var waitingForPoll: PendingCommand?
  • Whether a refresh was requested during the current exchange.

    Declaration

    Swift

    @MainActor
    private var needsRefresh: Bool
  • The scheduled poll for the next host snapshot.

    Declaration

    Swift

    @MainActor
    private var heartbeat: DispatchWorkItem?
  • The delayed complication rewind when the phone becomes unreachable.

    Declaration

    Swift

    @MainActor
    private var complicationRewind: DispatchWorkItem?
  • The host process identifier from the last valid interactive response.

    Declaration

    Swift

    @MainActor
    private var hostSession: String?
  • The command revision advertised in the last accepted snapshot.

    Declaration

    Swift

    @MainActor
    private var revision: Int
  • Recent measurements used to translate between the host and Watch clocks.

    Declaration

    Swift

    @MainActor
    private var clock: RiValT_RemoteState.Clock
  • Initializes the Watch’s timer link.

    Declaration

    Swift

    @MainActor
    init(activate: Bool = true)

    Parameters

    activate

    Whether to activate the transports immediately.

  • Installs the transport callbacks and activates WatchConnectivity and the iPad Bluetooth link.

    Declaration

    Swift

    @MainActor
    func activate()
  • Whether activation, pending session content, and complication writes have all finished.

    Declaration

    Swift

    @MainActor
    var canCompleteConnectivityTasks: Bool { get }
  • Whether the currently selected transport can send an interactive request.

    Declaration

    Swift

    @MainActor
    private var linkIsReachable: Bool { get }
  • Updates interactive polling and complication handling when the Watch scene changes activity.

    Declaration

    Swift

    @MainActor
    func setWatchActive(_ value: Bool)
  • The persisted complication source key for the selected phone or iPad.

    Declaration

    Swift

    @MainActor
    private var complicationSource: String { get }
  • Whether the activated phone session has lost interactive reachability.

    Declaration

    Swift

    @MainActor
    private var phoneIsUnreachable: Bool { get }
  • Rewinds the selected host’s stored complication at the current host time.

    Declaration

    Swift

    @MainActor
    private func rewindComplication()
  • Cancels a scheduled rewind when the phone recovers or the selected device changes.

    Declaration

    Swift

    @MainActor
    private func cancelComplicationRewind()
  • Rewinds immediately for iPad loss and delays a phone rewind to allow a transition to the watch face.

    Declaration

    Swift

    @MainActor
    private func handleComplicationConnectionLoss()
  • Resets interactive state, selects the complication source, and refreshes a reachable active host.

    Declaration

    Swift

    @MainActor
    private func connectionChanged()
  • Discards the live snapshot and host clock estimate, then notifies observers.

    Declaration

    Swift

    @MainActor
    private func clearSnapshot()
  • An explicit retry may reactivate a failed session or retry the selected iPad’s approval.

    Declaration

    Swift

    @MainActor
    func reconnect()
  • Wake, reconnection, user refresh and a host invalidation all take this same path.

    Declaration

    Swift

    @MainActor
    func refresh()
  • Sends the supported command or queues it with the displayed host revision until the current poll completes.

    Declaration

    Swift

    @MainActor
    func sendCommand(command: TimerOperation)
  • Sends a snapshot request or expiring command over the selected transport and starts a reply timeout.

    Declaration

    Swift

    @MainActor
    private func request(command: TimerOperation?, tapped: Date? = nil)
  • Clears the failed exchange, reports the connection loss, and schedules another poll.

    Declaration

    Swift

    @MainActor
    private func failed(id: String)
  • Validates the host reply, updates the clock and timer snapshot, and reconciles any queued command.

    Declaration

    Swift

    @MainActor
    private func received(_ reply: [String : Any], id: String, sent: Date, at received: Date, wasCommand: Bool)
  • Keep background execution until the main actor has stored the delivered snapshot.

    Declaration

    Swift

    private nonisolated func enqueueComplicationUpdate(_ payload: [String : Any])
  • Background data is for the face only; it never enables remote controls or establishes reachability.

    Declaration

    Swift

    @MainActor
    private func receiveComplicationUpdate(_ payload: [String : Any])
  • Schedules the next snapshot request while the Watch scene is active.

    Declaration

    Swift

    @MainActor
    private func scheduleRefresh(in seconds: TimeInterval)
  • Refreshes connection state after WatchConnectivity activation.

    Declaration

    Swift

    nonisolated func session(_ session: WCSession, activationDidCompleteWith state: WCSessionActivationState, error: Error?)
  • Reevaluates the Watch’s selected connection after a reachability change.

    Declaration

    Swift

    nonisolated func sessionReachabilityDidChange(_ session: WCSession)
  • Queues the paired phone’s latest application-context sample for the complication.

    Declaration

    Swift

    nonisolated func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : Any])
  • Queues a priority complication update received from the paired phone.

    Declaration

    Swift

    nonisolated func session(_ session: WCSession, didReceiveUserInfo userInfo: [String : Any])
  • Requests a new snapshot after the paired phone sends a change hint.

    Declaration

    Swift

    nonisolated func session(_ session: WCSession, didReceiveMessage message: [String : Any])