@xuda.io/xuda-worker-bundle-min 1.3.530 → 1.3.531
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +50 -27
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1064,6 +1064,7 @@ func.common.perform_rpi_request = async function (
|
|
|
1064
1064
|
opt = {},
|
|
1065
1065
|
data
|
|
1066
1066
|
) {
|
|
1067
|
+
var _session = SESSION_OBJ[SESSION_ID];
|
|
1067
1068
|
const http = async function () {
|
|
1068
1069
|
const fetchWithTimeout = (url, options = {}, timeout = 600000) => {
|
|
1069
1070
|
// 100 seconds
|
|
@@ -1160,41 +1161,63 @@ func.common.get_data_from_websocket = async function (
|
|
|
1160
1161
|
) {
|
|
1161
1162
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
1162
1163
|
return new Promise(function (resolve, reject) {
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1164
|
+
const dbs_calls = function () {
|
|
1165
|
+
glb.websocket_queue_num++;
|
|
1166
|
+
const obj = {
|
|
1167
|
+
service: serviceP,
|
|
1168
|
+
data,
|
|
1169
|
+
websocket_queue_num: glb.websocket_queue_num,
|
|
1170
|
+
};
|
|
1171
|
+
if (glb.IS_WORKER) {
|
|
1172
|
+
func.utils.post_back_to_client(
|
|
1173
|
+
SESSION_ID,
|
|
1174
|
+
"get_dbs_data_from_websocket",
|
|
1175
|
+
_session.worker_id,
|
|
1176
|
+
obj
|
|
1177
|
+
);
|
|
1176
1178
|
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1179
|
+
self.addEventListener(
|
|
1180
|
+
"get_ws_data_worker_" + glb.websocket_queue_num,
|
|
1181
|
+
(event) => {
|
|
1182
|
+
resolve(event.detail.data);
|
|
1183
|
+
}
|
|
1184
|
+
);
|
|
1185
|
+
// throw new Error("not ready yet");
|
|
1186
|
+
} else {
|
|
1187
|
+
if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED) {
|
|
1188
|
+
RUNTIME_SERVER_WEBSOCKET.emit("message", obj);
|
|
1189
|
+
$("body").on(
|
|
1190
|
+
"get_ws_data_response_" + glb.websocket_queue_num,
|
|
1191
|
+
(e, data) => {
|
|
1192
|
+
resolve(data.data);
|
|
1193
|
+
$("body").off("get_ws_data_response_" + glb.websocket_queue_num);
|
|
1194
|
+
}
|
|
1195
|
+
);
|
|
1196
|
+
} else {
|
|
1197
|
+
throw new Error("fail to fetch from ws websocket inactive");
|
|
1181
1198
|
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
const heartbeat = function () {
|
|
1202
|
+
const obj = {
|
|
1203
|
+
service: "heartbeat",
|
|
1204
|
+
data,
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1185
1207
|
if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED) {
|
|
1186
1208
|
RUNTIME_SERVER_WEBSOCKET.emit("message", obj);
|
|
1187
|
-
$("body").on(
|
|
1188
|
-
|
|
1189
|
-
(
|
|
1190
|
-
|
|
1191
|
-
$("body").off("get_ws_data_response_" + glb.websocket_queue_num);
|
|
1192
|
-
}
|
|
1193
|
-
);
|
|
1209
|
+
$("body").on("heartbeat_response", (e, data) => {
|
|
1210
|
+
resolve(data.data);
|
|
1211
|
+
$("body").off("heartbeat_response");
|
|
1212
|
+
});
|
|
1194
1213
|
} else {
|
|
1195
1214
|
throw new Error("fail to fetch from ws websocket inactive");
|
|
1196
1215
|
}
|
|
1216
|
+
};
|
|
1217
|
+
if (serviceP === "heartbeat") {
|
|
1218
|
+
return heartbeat();
|
|
1197
1219
|
}
|
|
1220
|
+
dbs_calls();
|
|
1198
1221
|
});
|
|
1199
1222
|
};
|
|
1200
1223
|
glb.DEBUG_INFO_OBJ = {};
|