Merge branch 'feat-training' into test
This commit is contained in:
+5
-16
@@ -87,28 +87,17 @@ function createWebSocket(token, onMessage) {
|
||||
|
||||
const { data, event, code, timestamp } = response || {};
|
||||
if (event === "pong") return;
|
||||
const passthroughEvents = [
|
||||
"/addons/shoot/battery",
|
||||
"/addons/shoot/otaProgress",
|
||||
"/addons/shoot/otaResult",
|
||||
];
|
||||
if (passthroughEvents.includes(event)) {
|
||||
if ((code == null || Number(code) === 0) && onMessage && data && typeof data === "object") {
|
||||
onMessage({ event, data, code, timestamp });
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (data?.type) {
|
||||
if (!data || typeof data !== "object") return;
|
||||
if (data.type) {
|
||||
if (ENABLE_REALTIME_MESSAGE_LOG) {
|
||||
console.log("收到 WebSocket 消息", getMessageTypeName(data.type));
|
||||
}
|
||||
if (onMessage) onMessage({ ...(data.data || {}), type: data.type });
|
||||
return;
|
||||
}
|
||||
const updates = Array.isArray(data?.updates) ? data.updates : [];
|
||||
if (!updates.length) return;
|
||||
if (onMessage) onMessage(updates);
|
||||
const msg = updates[0];
|
||||
if (!Array.isArray(data.updates)) return;
|
||||
if (onMessage) onMessage(data.updates);
|
||||
const msg = data.updates[0];
|
||||
if (msg) {
|
||||
if (ENABLE_REALTIME_MESSAGE_LOG) {
|
||||
console.log(
|
||||
|
||||
Reference in New Issue
Block a user