fix: 自动开启机巢图传并修复日志崩溃与订阅重连

This commit is contained in:
2026-11-03 10:18:23 +08:00
parent 203799b2f4
commit 5d48e37cd7
12 changed files with 301 additions and 36 deletions
@@ -14,7 +14,13 @@ enum DroneDockShootingSocketMessage {
/// WebSocket 成功码为 0,不使用 HTTP 的 100000 Envelope。
static func decode(_ data: Data) throws -> Self {
guard let root = try JSONSerialization.jsonObject(with: data) as? [String: Any],
// 服务端建连先发 Opened。它不代表 310 订阅成功,也不能取消订阅超时或 HTTP 兜底。
if String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines) == "Opened" {
return .unrelated
}
let json = try JSONSerialization.jsonObject(with: data, options: .fragmentsAllowed)
if json as? String == "Opened" { return .unrelated }
guard let root = json as? [String: Any],
let code = root["code"] as? Int else { throw APIError.invalidResponse }
if code != 0 {
return .rejected(code: code, message: root["msg"] as? String ?? "任务订阅失败")