@xuda.io/xuda-worker-bundle-min 1.3.487 → 1.3.489
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 +96 -79
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1019,34 +1019,49 @@ func.common.perform_rpi_request = async function (
|
|
|
1019
1019
|
opt = {},
|
|
1020
1020
|
data
|
|
1021
1021
|
) {
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1022
|
+
debugger;
|
|
1023
|
+
const http = async function () {
|
|
1024
|
+
var url = func.common.get_url(SESSION_ID, "rpi", "");
|
|
1025
|
+
var _session = SESSION_OBJ[SESSION_ID];
|
|
1026
|
+
const app_id = _session.APP_ID;
|
|
1025
1027
|
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1028
|
+
if (
|
|
1029
|
+
APP_OBJ[app_id].is_deployment &&
|
|
1030
|
+
_session.rpi_http_methods?.includes(serviceP)
|
|
1031
|
+
) {
|
|
1032
|
+
url = "https://" + _session.host + "/rpi/";
|
|
1033
|
+
}
|
|
1032
1034
|
|
|
1033
|
-
|
|
1035
|
+
url += serviceP;
|
|
1034
1036
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1037
|
+
try {
|
|
1038
|
+
const response = await fetch(url, {
|
|
1039
|
+
method: opt.type ? opt.type : "POST",
|
|
1040
|
+
headers: {
|
|
1041
|
+
Accept: "application/json",
|
|
1042
|
+
"Content-Type": "application/json",
|
|
1043
|
+
},
|
|
1044
|
+
body: JSON.stringify(data),
|
|
1045
|
+
});
|
|
1046
|
+
if (!response.ok) throw "";
|
|
1047
|
+
const json = await response.json();
|
|
1048
|
+
return json;
|
|
1049
|
+
} catch (err) {
|
|
1050
|
+
console.error(err);
|
|
1051
|
+
return {};
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
const ws = async function () {
|
|
1055
|
+
RUNTIME_SERVER_WEBSOCKET.emit("message", {
|
|
1056
|
+
service: serviceP,
|
|
1057
|
+
data,
|
|
1043
1058
|
});
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
return
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED) {
|
|
1062
|
+
return await ws();
|
|
1063
|
+
} else {
|
|
1064
|
+
return await http();
|
|
1050
1065
|
}
|
|
1051
1066
|
};
|
|
1052
1067
|
glb.DEBUG_INFO_OBJ = {};
|
|
@@ -5047,15 +5062,17 @@ func.utils.job_worker = function (session_id) {
|
|
|
5047
5062
|
_this._was_busy = true;
|
|
5048
5063
|
} else {
|
|
5049
5064
|
// idle
|
|
5050
|
-
if (
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5065
|
+
if (_this._was_busy) {
|
|
5066
|
+
if (glb.IS_WORKER) {
|
|
5067
|
+
func.utils.post_back_to_client(
|
|
5068
|
+
SESSION_ID,
|
|
5069
|
+
"worker_busy_off",
|
|
5070
|
+
_session.worker_id,
|
|
5071
|
+
null
|
|
5072
|
+
);
|
|
5073
|
+
} else {
|
|
5074
|
+
func.UI.utils.indicator.worker.normal();
|
|
5075
|
+
}
|
|
5059
5076
|
}
|
|
5060
5077
|
_this._was_busy = false;
|
|
5061
5078
|
}
|
|
@@ -5729,54 +5746,54 @@ func.utils.ws_worker.functions = {
|
|
|
5729
5746
|
data: params,
|
|
5730
5747
|
});
|
|
5731
5748
|
},
|
|
5732
|
-
heartbeat: async function (params) {
|
|
5733
|
-
|
|
5749
|
+
// heartbeat: async function (params) {
|
|
5750
|
+
// var SESSION_ID = params.session_id;
|
|
5734
5751
|
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5752
|
+
// try {
|
|
5753
|
+
// const do_heartbeat = async function (
|
|
5754
|
+
// app_replicate,
|
|
5755
|
+
// app_id,
|
|
5756
|
+
// token_id,
|
|
5757
|
+
// fingerprint,
|
|
5758
|
+
// device_name,
|
|
5759
|
+
// stat
|
|
5760
|
+
// ) {
|
|
5761
|
+
// try {
|
|
5762
|
+
// module.exports.close_expired_device_log_sessions(app_id);
|
|
5763
|
+
|
|
5764
|
+
// return await update_device(
|
|
5765
|
+
// app_replicate,
|
|
5766
|
+
// app_id,
|
|
5767
|
+
// token_id,
|
|
5768
|
+
// fingerprint,
|
|
5769
|
+
// device_name,
|
|
5770
|
+
// stat
|
|
5771
|
+
// );
|
|
5772
|
+
// } catch (err) {
|
|
5773
|
+
// return { code: -400, data: err.message };
|
|
5774
|
+
// }
|
|
5775
|
+
// };
|
|
5776
|
+
// let ret = await do_heartbeat(
|
|
5777
|
+
// params.app_replicate,
|
|
5778
|
+
// params.app_id,
|
|
5779
|
+
// params.gtp_token || req.body.token,
|
|
5780
|
+
// params.fingerprint,
|
|
5781
|
+
// params.device_name,
|
|
5782
|
+
// params.stat
|
|
5783
|
+
// );
|
|
5767
5784
|
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
},
|
|
5785
|
+
// // session_status: ret_session.data.stat
|
|
5786
|
+
// if (params.token) {
|
|
5787
|
+
// try {
|
|
5788
|
+
// const couch = await __.rpi.get_app_couch(req.body.app_id);
|
|
5789
|
+
// const session_doc = await couch.get(req.body.token);
|
|
5790
|
+
// ret.session_stat = session_doc.stat;
|
|
5791
|
+
// } catch (error) {}
|
|
5792
|
+
// }
|
|
5793
|
+
// } catch (error) {
|
|
5794
|
+
// debugger;
|
|
5795
|
+
// }
|
|
5796
|
+
// },
|
|
5780
5797
|
return_rpi_request_from_studio: function (params) {
|
|
5781
5798
|
var SESSION_ID = params.session_id;
|
|
5782
5799
|
function emitCustomEvent(eventName, detail) {
|