feat(drone-dock): 接入火山实时图传并保留禁飞保护
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import SnapKit
|
||||
import UIKit
|
||||
|
||||
/// 拍摄任务页:真实入口只读,本地模拟入口可验证图传、重召唤、开拍与安全指令合同。
|
||||
/// 拍摄任务页:正式入口读取状态并手动开启图传,飞控仅在隔离模拟入口注入。
|
||||
@MainActor
|
||||
final class DroneDockShootingTaskViewController: BaseViewController {
|
||||
/// 入口传入的固定任务身份及只读状态,供导航协调和页面测试检查。
|
||||
@@ -173,6 +173,13 @@ final class DroneDockShootingTaskViewController: BaseViewController {
|
||||
statusView.onDetails = { [weak self] in self?.showStatusDetails() }
|
||||
safetyView.onCommand = { [weak self] command in self?.safetyCommandTriggered(command) }
|
||||
feedPlaceholder.onRequest = { [weak self] in self?.refreshLiveIfVisible() }
|
||||
feedPlaceholder.onPlaybackEvent = { [weak self] event, sessionID in
|
||||
Task { @MainActor [weak self] in
|
||||
guard let self, self.isPageVisible, self.isApplicationActive else { return }
|
||||
self.liveViewModel.receivePlaybackEvent(event, sessionID: sessionID)
|
||||
self.applySnapshot()
|
||||
}
|
||||
}
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(applicationWillResignActive),
|
||||
name: UIApplication.willResignActiveNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(applicationDidBecomeActive),
|
||||
@@ -185,7 +192,7 @@ final class DroneDockShootingTaskViewController: BaseViewController {
|
||||
isPageVisible = true
|
||||
isApplicationActive = UIApplication.shared.applicationState == .active
|
||||
refreshTaskIfVisible()
|
||||
refreshLiveIfVisible()
|
||||
refreshLiveIfVisible(automatically: true)
|
||||
}
|
||||
|
||||
/// 离页立即取消未完成的读取,使迟到响应失效。
|
||||
@@ -352,8 +359,9 @@ final class DroneDockShootingTaskViewController: BaseViewController {
|
||||
}
|
||||
}
|
||||
|
||||
/// 图传只读取一次,不轮询;正式入口没有图传服务,不能向设备发出开流请求。
|
||||
private func refreshLiveIfVisible() {
|
||||
/// 图传请求不轮询;正式入口仅响应用户点击,本地样片允许随页面加载。
|
||||
private func refreshLiveIfVisible(automatically: Bool = false) {
|
||||
guard !automatically || liveViewModel.loadsAutomatically else { return }
|
||||
guard isPageVisible, isApplicationActive, liveTask == nil, liveViewModel.canLoad else { return }
|
||||
liveGeneration &+= 1
|
||||
let generation = liveGeneration
|
||||
@@ -446,7 +454,7 @@ final class DroneDockShootingTaskViewController: BaseViewController {
|
||||
guard !isApplicationActive else { return }
|
||||
isApplicationActive = true
|
||||
refreshTaskIfVisible()
|
||||
refreshLiveIfVisible()
|
||||
refreshLiveIfVisible(automatically: true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user