@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.
Files changed (2) hide show
  1. package/index.js +96 -79
  2. 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
- var url = func.common.get_url(SESSION_ID, "rpi", "");
1023
- var _session = SESSION_OBJ[SESSION_ID];
1024
- const app_id = _session.APP_ID;
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
- if (
1027
- APP_OBJ[app_id].is_deployment &&
1028
- _session.rpi_http_methods?.includes(serviceP)
1029
- ) {
1030
- url = "https://" + _session.host + "/rpi/";
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
- url += serviceP;
1035
+ url += serviceP;
1034
1036
 
1035
- try {
1036
- const response = await fetch(url, {
1037
- method: opt.type ? opt.type : "POST",
1038
- headers: {
1039
- Accept: "application/json",
1040
- "Content-Type": "application/json",
1041
- },
1042
- body: JSON.stringify(data),
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
- if (!response.ok) throw "";
1045
- const json = await response.json();
1046
- return json;
1047
- } catch (err) {
1048
- console.error(err);
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 (glb.IS_WORKER) {
5051
- func.utils.post_back_to_client(
5052
- SESSION_ID,
5053
- "worker_busy_off",
5054
- _session.worker_id,
5055
- null
5056
- );
5057
- } else {
5058
- func.UI.utils.indicator.worker.normal();
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
- var SESSION_ID = params.session_id;
5749
+ // heartbeat: async function (params) {
5750
+ // var SESSION_ID = params.session_id;
5734
5751
 
5735
- try {
5736
- const do_heartbeat = async function (
5737
- app_replicate,
5738
- app_id,
5739
- token_id,
5740
- fingerprint,
5741
- device_name,
5742
- stat
5743
- ) {
5744
- try {
5745
- module.exports.close_expired_device_log_sessions(app_id);
5746
-
5747
- return await update_device(
5748
- app_replicate,
5749
- app_id,
5750
- token_id,
5751
- fingerprint,
5752
- device_name,
5753
- stat
5754
- );
5755
- } catch (err) {
5756
- return { code: -400, data: err.message };
5757
- }
5758
- };
5759
- let ret = await do_heartbeat(
5760
- params.app_replicate,
5761
- params.app_id,
5762
- params.gtp_token || req.body.token,
5763
- params.fingerprint,
5764
- params.device_name,
5765
- params.stat
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
- // session_status: ret_session.data.stat
5769
- if (params.token) {
5770
- try {
5771
- const couch = await __.rpi.get_app_couch(req.body.app_id);
5772
- const session_doc = await couch.get(req.body.token);
5773
- ret.session_stat = session_doc.stat;
5774
- } catch (error) {}
5775
- }
5776
- } catch (error) {
5777
- debugger;
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle-min",
3
- "version": "1.3.487",
3
+ "version": "1.3.489",
4
4
  "description": "xuda framework min",
5
5
  "main": "index.js",
6
6
  "scripts": {