@resolveio/server-lib 12.4.18 → 12.4.20

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.
@@ -170,7 +170,7 @@ var SubscriptionManager = /** @class */ (function () {
170
170
  _this._debugRemoveCacheHits = 0;
171
171
  }, 60000);
172
172
  setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
173
- var _loop_1, this_1, i, queueArr, mongoQueue_1, promises, _loop_2, this_2, j;
173
+ var _loop_1, this_1, i, queueArr, _loop_2, this_2, i;
174
174
  var _this = this;
175
175
  return __generator(this, function (_a) {
176
176
  if (!this._runningQueue) {
@@ -216,121 +216,70 @@ var SubscriptionManager = /** @class */ (function () {
216
216
  }
217
217
  queueArr = this._mongoQueue.filter(function (a) { return !a.running; });
218
218
  if (queueArr.length) {
219
- // queueArr.forEach(entry => {
220
- // entry.running = true;
221
- // });
222
- // for (let i = queueArr.length - 1; i >= 0; i--) {
223
- // this._debugMongoQueueHits += 1;
224
- // let mongoQueue = queueArr[i];
225
- // if (!this._debugMongoQueueCollections.some(a => a.collection === mongoQueue.collection && a.publication === mongoQueue.subscription.publication)) {
226
- // this._debugMongoQueueCollections.push({
227
- // collection: mongoQueue.collection,
228
- // publication: mongoQueue.subscription.publication,
229
- // hits: 1
230
- // });
231
- // }
232
- // else {
233
- // this._debugMongoQueueCollections.filter(a => a.collection === mongoQueue.collection && a.publication === mongoQueue.subscription.publication)[0].hits += 1;
234
- // }
235
- // if (this._publications[mongoQueue.subscription.publication].user_specific) {
236
- // let promises = [];
237
- // for (let j = 0; j < mongoQueue.subscription.clients.length; j++) {
238
- // let client = mongoQueue.subscription.clients[j];
239
- // let ws = this._mainServer.getWS(client.id_socket);
240
- // if (ws && ws['id_socket'] === client.id_socket) {
241
- // promises.push(this.sendDataToOne(ws, client.messageId, mongoQueue.subscription, mongoQueue.type, mongoQueue.collection).catch((err) => {
242
- // this._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During sendDataToOne - User Specific - Socket: ' + client.id_socket + ', User: ' + client.id_user + ', MessageId: ' + client.messageId + ', Pub: ' + mongoQueue.subscription.publication + ', Err: ' + JSON.stringify(err, null, 2));
243
- // return null;
244
- // }));
245
- // }
246
- // }
247
- // Promise.all(promises).then(() => {
248
- // if (mongoQueue.run_again) {
249
- // mongoQueue.running = false;
250
- // mongoQueue.run_again = false;
251
- // }
252
- // else {
253
- // if (this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id) >= 0) {
254
- // this._mongoQueue.splice(this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id), 1);
255
- // }
256
- // }
257
- // });
258
- // }
259
- // else {
260
- // this.sendDataToAll(mongoQueue).then(() => {
261
- // if (mongoQueue.run_again) {
262
- // mongoQueue.running = false;
263
- // mongoQueue.run_again = false;
264
- // }
265
- // else {
266
- // if (this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id) >= 0) {
267
- // this._mongoQueue.splice(this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id), 1);
268
- // }
269
- // }
270
- // }, () => {
271
- // if (this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id) >= 0) {
272
- // this._mongoQueue.splice(this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id), 1);
273
- // }
274
- // });
275
- // }
276
- // }
277
- this._debugMongoQueueHits += 1;
278
- mongoQueue_1 = queueArr[queueArr.length - 1];
279
- mongoQueue_1.running = true;
280
- if (!this._debugMongoQueueCollections.some(function (a) { return a.collection === mongoQueue_1.collection && a.publication === mongoQueue_1.subscription.publication; })) {
281
- this._debugMongoQueueCollections.push({
282
- collection: mongoQueue_1.collection,
283
- publication: mongoQueue_1.subscription.publication,
284
- hits: 1
285
- });
286
- }
287
- else {
288
- this._debugMongoQueueCollections.filter(function (a) { return a.collection === mongoQueue_1.collection && a.publication === mongoQueue_1.subscription.publication; })[0].hits += 1;
289
- }
290
- if (this._publications[mongoQueue_1.subscription.publication].user_specific) {
291
- promises = [];
292
- _loop_2 = function (j) {
293
- var client = mongoQueue_1.subscription.clients[j];
294
- var ws = this_2._mainServer.getWS(client.id_socket);
295
- if (ws && ws['id_socket'] === client.id_socket) {
296
- promises.push(this_2.sendDataToOne(ws, client.messageId, mongoQueue_1.subscription, mongoQueue_1.type, mongoQueue_1.collection).catch(function (err) {
297
- _this._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'Error Detected During sendDataToOne - User Specific - Socket: ' + client.id_socket + ', User: ' + client.id_user + ', MessageId: ' + client.messageId + ', Pub: ' + mongoQueue_1.subscription.publication + ', Err: ' + JSON.stringify(err, null, 2));
298
- return null;
299
- }));
300
- }
301
- };
302
- this_2 = this;
303
- for (j = 0; j < mongoQueue_1.subscription.clients.length; j++) {
304
- _loop_2(j);
219
+ queueArr.forEach(function (entry) {
220
+ entry.running = true;
221
+ });
222
+ _loop_2 = function (i) {
223
+ this_2._debugMongoQueueHits += 1;
224
+ var mongoQueue = queueArr[i];
225
+ if (!this_2._debugMongoQueueCollections.some(function (a) { return a.collection === mongoQueue.collection && a.publication === mongoQueue.subscription.publication; })) {
226
+ this_2._debugMongoQueueCollections.push({
227
+ collection: mongoQueue.collection,
228
+ publication: mongoQueue.subscription.publication,
229
+ hits: 1
230
+ });
305
231
  }
306
- Promise.all(promises).then(function () {
307
- if (mongoQueue_1.run_again) {
308
- mongoQueue_1.running = false;
309
- mongoQueue_1.run_again = false;
310
- }
311
- else {
312
- if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue_1._id) >= 0) {
313
- _this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue_1._id), 1);
232
+ else {
233
+ this_2._debugMongoQueueCollections.filter(function (a) { return a.collection === mongoQueue.collection && a.publication === mongoQueue.subscription.publication; })[0].hits += 1;
234
+ }
235
+ if (this_2._publications[mongoQueue.subscription.publication].user_specific) {
236
+ var promises = [];
237
+ var _loop_3 = function (j) {
238
+ var client = mongoQueue.subscription.clients[j];
239
+ var ws = this_2._mainServer.getWS(client.id_socket);
240
+ if (ws && ws['id_socket'] === client.id_socket) {
241
+ promises.push(this_2.sendDataToOne(ws, client.messageId, mongoQueue.subscription, mongoQueue.type, mongoQueue.collection).catch(function (err) {
242
+ _this._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'Error Detected During sendDataToOne - User Specific - Socket: ' + client.id_socket + ', User: ' + client.id_user + ', MessageId: ' + client.messageId + ', Pub: ' + mongoQueue.subscription.publication + ', Err: ' + JSON.stringify(err, null, 2));
243
+ return null;
244
+ }));
314
245
  }
246
+ };
247
+ for (var j = 0; j < mongoQueue.subscription.clients.length; j++) {
248
+ _loop_3(j);
315
249
  }
316
- });
317
- }
318
- else {
319
- this.sendDataToAll(mongoQueue_1).then(function () {
320
- if (mongoQueue_1.run_again) {
321
- mongoQueue_1.running = false;
322
- mongoQueue_1.run_again = false;
323
- }
324
- else {
325
- if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue_1._id) >= 0) {
326
- _this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue_1._id), 1);
250
+ Promise.all(promises).then(function () {
251
+ if (mongoQueue.run_again) {
252
+ mongoQueue.running = false;
253
+ mongoQueue.run_again = false;
327
254
  }
328
- }
329
- }, function () {
330
- if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue_1._id) >= 0) {
331
- _this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue_1._id), 1);
332
- }
333
- });
255
+ else {
256
+ if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id) >= 0) {
257
+ _this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
258
+ }
259
+ }
260
+ });
261
+ }
262
+ else {
263
+ this_2.sendDataToAll(mongoQueue).then(function () {
264
+ if (mongoQueue.run_again) {
265
+ mongoQueue.running = false;
266
+ mongoQueue.run_again = false;
267
+ }
268
+ else {
269
+ if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id) >= 0) {
270
+ _this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
271
+ }
272
+ }
273
+ }, function () {
274
+ if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id) >= 0) {
275
+ _this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
276
+ }
277
+ });
278
+ }
279
+ };
280
+ this_2 = this;
281
+ for (i = queueArr.length - 1; i >= 0; i--) {
282
+ _loop_2(i);
334
283
  }
335
284
  // let endDate = new Date();
336
285
  // this.currentPerfomanceMonitor.push({
@@ -348,9 +297,9 @@ var SubscriptionManager = /** @class */ (function () {
348
297
  }
349
298
  return [2 /*return*/];
350
299
  });
351
- }); }, 25);
300
+ }); }, 250);
352
301
  setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
353
- var _a, userCopy, _loop_3, this_3, i, i, sub, _loop_4, this_4, j;
302
+ var _a, userCopy, _loop_4, this_3, i, i, sub, _loop_5, this_4, j;
354
303
  return __generator(this, function (_b) {
355
304
  switch (_b.label) {
356
305
  case 0:
@@ -359,7 +308,7 @@ var SubscriptionManager = /** @class */ (function () {
359
308
  case 1:
360
309
  _a._loggedInUsers = _b.sent();
361
310
  userCopy = common_1.deepCopy(this._loggedInUsers);
362
- _loop_3 = function (i) {
311
+ _loop_4 = function (i) {
363
312
  var loggedInUser = userCopy[i];
364
313
  if (!loggedInUser.date || Date.now() - loggedInUser.date.getTime() > 120000) {
365
314
  if (this_3._mainServer.getWS(loggedInUser.id_ws)) {
@@ -386,11 +335,11 @@ var SubscriptionManager = /** @class */ (function () {
386
335
  };
387
336
  this_3 = this;
388
337
  for (i = this._loggedInUsers.length - 1; i >= 0; i--) {
389
- _loop_3(i);
338
+ _loop_4(i);
390
339
  }
391
340
  for (i = 0; i < this._subscriptions.length; i++) {
392
341
  sub = this._subscriptions[i];
393
- _loop_4 = function (j) {
342
+ _loop_5 = function (j) {
394
343
  var client = sub.clients[j];
395
344
  if (!this_4._loggedInUsers.some(function (a) { return a.id_ws === client.id_socket; })) {
396
345
  sub.clients.splice(j, 1);
@@ -398,7 +347,7 @@ var SubscriptionManager = /** @class */ (function () {
398
347
  };
399
348
  this_4 = this;
400
349
  for (j = sub.clients.length - 1; j >= 0; j--) {
401
- _loop_4(j);
350
+ _loop_5(j);
402
351
  }
403
352
  }
404
353
  return [2 /*return*/];