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