@xuda.io/xuda-worker-bundle-min 1.3.516 → 1.3.517

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 +49 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1132,18 +1132,63 @@ func.common.perform_rpi_request = async function (
1132
1132
 
1133
1133
  try {
1134
1134
  if (
1135
- RUNTIME_SERVER_WEBSOCKET &&
1136
- RUNTIME_SERVER_WEBSOCKET_CONNECTED &&
1135
+ // RUNTIME_SERVER_WEBSOCKET &&
1136
+ // RUNTIME_SERVER_WEBSOCKET_CONNECTED &&
1137
1137
  SESSION_OBJ?.[SESSION_ID]?.rpi_http_methods?.includes(serviceP)
1138
1138
  ) {
1139
- return await ws();
1139
+ // return await ws();
1140
+ return await func.common.get_data_from_websocket(
1141
+ SESSION_ID,
1142
+ serviceP,
1143
+ data
1144
+ );
1140
1145
  } else {
1141
- throw new Error("fail to fetch from ws websocket inactive");
1146
+ throw new Error("method not found in rpi_http_methods");
1142
1147
  }
1143
1148
  } catch (err) {
1144
1149
  return await http();
1145
1150
  }
1146
1151
  };
1152
+
1153
+ func.common.get_data_from_websocket = async function (
1154
+ SESSION_ID,
1155
+ serviceP,
1156
+ data
1157
+ ) {
1158
+ var _session = _this.SESSION_OBJ[SESSION_ID];
1159
+ return new Promise(function (resolve, reject) {
1160
+ glb.websocket_queue_num++;
1161
+ if (glb.IS_WORKER) {
1162
+ func.utils.post_back_to_client(
1163
+ SESSION_ID,
1164
+ "get_doc_from_websocket",
1165
+ _session.worker_id,
1166
+ { doc_id: idP }
1167
+ );
1168
+
1169
+ self.addEventListener("get_doc_obj_from_build_worker_" + idP, (event) => {
1170
+ resolve(event.detail.data);
1171
+ });
1172
+ } else {
1173
+ if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED) {
1174
+ RUNTIME_SERVER_WEBSOCKET.emit("message", {
1175
+ service: serviceP,
1176
+ data,
1177
+ websocket_queue_num: glb.websocket_queue_num,
1178
+ });
1179
+ $("body").on(
1180
+ "get_ws_data_response_" + glb.websocket_queue_num,
1181
+ (e, data) => {
1182
+ resolve(data.data);
1183
+ $("body").off("get_ws_data_response_" + glb.websocket_queue_num);
1184
+ }
1185
+ );
1186
+ } else {
1187
+ throw new Error("fail to fetch from ws websocket inactive");
1188
+ }
1189
+ }
1190
+ });
1191
+ };
1147
1192
  glb.DEBUG_INFO_OBJ = {};
1148
1193
  // var CONNECTION_ATTEMPTS = 0;
1149
1194
  glb.APP_INFO = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle-min",
3
- "version": "1.3.516",
3
+ "version": "1.3.517",
4
4
  "description": "xuda framework min",
5
5
  "main": "index.js",
6
6
  "scripts": {