适配上传中订单并完善机巢操作与订阅兜底

支持订单状态 25 和持续拍摄、交付确认;安全指令点击后直接提交;鉴权超时保留 HTTP 兜底并退避换票重连。补充对应隔离回归测试。
This commit is contained in:
2026-11-05 12:35:58 +08:00
parent 34ee60b8b2
commit cd90c3648b
18 changed files with 373 additions and 71 deletions
@@ -18,6 +18,7 @@ enum DroneDockShootingSocketMessage {
case subscribed(taskID: Int)
case subscriptionMetadata(taskID: Int, hasSnapshot: Bool, executionBatch: Int?)
case snapshot(DroneDockShootingResponse)
case subscriptionTimedOut(message: String)
case subscriptionRejected(code: Int, message: String)
case rejected(code: Int, message: String)
case unrelated
@@ -32,10 +33,19 @@ enum DroneDockShootingSocketMessage {
if json as? String == "Opened" { return .opened }
guard let root = json as? [String: Any],
let code = root["code"] as? Int else { throw APIError.invalidResponse }
// 鉴权硬超时是服务暂不可用。合同以正式失败回执的 hint 标识,未约定专用错误码;
// 即使返回 100099,也不能按无权限永久关闭 HTTP 和 Socket 读取。
if let body = root["data"] as? [String: Any],
body["type"] as? Int == 310, body["ack"] as? String == "subscribe",
boolean(body["subscribed"]) == false,
let hint = body["hint"] as? String, hint.contains("鉴权超时") {
return .subscriptionTimedOut(message: hint.trimmingCharacters(in: .whitespacesAndNewlines))
}
if code != 100000 {
let message = root["msg"] as? String ?? "任务订阅失败"
if let body = root["data"] as? [String: Any],
body["type"] as? Int == 310, boolean(body["subscribed"]) == false {
body["type"] as? Int == 310, body["ack"] as? String == "subscribe",
boolean(body["subscribed"]) == false {
return .subscriptionRejected(code: code, message: message)
}
return .rejected(code: code, message: message)