@resolveio/server-lib 9.8.13 → 9.9.1
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/managers/mongo.manager.d.ts +0 -1
- package/managers/mongo.manager.js +39 -28
- package/managers/mongo.manager.js.map +1 -1
- package/managers/subscription.manager.d.ts +3 -3
- package/managers/subscription.manager.js +100 -76
- package/managers/subscription.manager.js.map +1 -1
- package/models/subscription.model.d.ts +1 -0
- package/models/subscription.model.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,7 +19,7 @@ export declare class SubscriptionManager {
|
|
|
19
19
|
private _heapLimit;
|
|
20
20
|
constructor(mainServer: any, wss: WebSocket.Server, serverConfig: any);
|
|
21
21
|
private addToQueue;
|
|
22
|
-
invalidatePubsCache(collection: any, type: any
|
|
22
|
+
invalidatePubsCache(collection: any, type: any): void;
|
|
23
23
|
publications(method: SubscriptionModel): void;
|
|
24
24
|
loggedInLatency(ws: WebSocket): Promise<void>;
|
|
25
25
|
subscribe(messageDate: Date, ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]): void;
|
|
@@ -28,7 +28,7 @@ export declare class SubscriptionManager {
|
|
|
28
28
|
unsubscribeAll(ws: WebSocket): Promise<void>;
|
|
29
29
|
private getPublicationCollections;
|
|
30
30
|
private tailOpLog;
|
|
31
|
-
private
|
|
32
|
-
private
|
|
31
|
+
private sendDataToOne;
|
|
32
|
+
private sendDataToAll;
|
|
33
33
|
private sendWS;
|
|
34
34
|
}
|
|
@@ -128,7 +128,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
128
128
|
report_builder_dashboard_builders_1.loadReportBuilderDashboardBuilderPublications(this);
|
|
129
129
|
this.tailOpLog();
|
|
130
130
|
setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
131
|
-
var _loop_1, this_1, i, queueArr,
|
|
131
|
+
var _loop_1, this_1, i, queueArr, _loop_2, this_2, i;
|
|
132
132
|
var _this = this;
|
|
133
133
|
return __generator(this, function (_a) {
|
|
134
134
|
if (!this._runningQueue) {
|
|
@@ -168,33 +168,58 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
168
168
|
// result: 'Done'
|
|
169
169
|
// });
|
|
170
170
|
}
|
|
171
|
-
queueArr = this._mongoQueue.filter(function (a) { return !a.running; });
|
|
171
|
+
queueArr = this._mongoQueue.filter(function (a) { return !a.running && (!a.subscription.next_run || a.subscription.next_run.getTime() <= Date.now()); });
|
|
172
172
|
if (queueArr.length) {
|
|
173
173
|
queueArr.forEach(function (entry) {
|
|
174
174
|
entry.running = true;
|
|
175
175
|
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
ws = this._mainServer.getWS(client.id_socket);
|
|
176
|
+
_loop_2 = function (i) {
|
|
177
|
+
var mongoQueue = queueArr[i];
|
|
178
|
+
if (this_2._publications[mongoQueue.subscription.publication].ws_specific) {
|
|
179
|
+
for (var j = 0; j < mongoQueue.subscription.clients.length; j++) {
|
|
180
|
+
var client = mongoQueue.subscription.clients[j];
|
|
181
|
+
var ws = this_2._mainServer.getWS(client.id_socket);
|
|
183
182
|
if (ws && ws['id_socket'] === client.id_socket) {
|
|
184
|
-
|
|
183
|
+
this_2.sendDataToOne(ws, client.messageId, mongoQueue.subscription, mongoQueue.type, mongoQueue.collection).then(function () {
|
|
184
|
+
if (mongoQueue.run_again) {
|
|
185
|
+
mongoQueue.running = false;
|
|
186
|
+
mongoQueue.run_again = false;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id) >= 0) {
|
|
190
|
+
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}, function () {
|
|
194
|
+
if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id) >= 0) {
|
|
195
|
+
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
185
198
|
}
|
|
186
199
|
}
|
|
187
200
|
}
|
|
188
201
|
else {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
202
|
+
this_2.sendDataToAll(mongoQueue).then(function () {
|
|
203
|
+
if (mongoQueue.run_again) {
|
|
204
|
+
mongoQueue.running = false;
|
|
205
|
+
mongoQueue.run_again = false;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id) >= 0) {
|
|
209
|
+
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}, function () {
|
|
213
|
+
if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id) >= 0) {
|
|
214
|
+
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
197
217
|
}
|
|
218
|
+
};
|
|
219
|
+
this_2 = this;
|
|
220
|
+
// let startDate = new Date();
|
|
221
|
+
for (i = queueArr.length - 1; i >= 0; i--) {
|
|
222
|
+
_loop_2(i);
|
|
198
223
|
}
|
|
199
224
|
// let endDate = new Date();
|
|
200
225
|
// this.currentPerfomanceMonitor.push({
|
|
@@ -214,7 +239,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
214
239
|
});
|
|
215
240
|
}); }, 1);
|
|
216
241
|
setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
217
|
-
var _a, userCopy,
|
|
242
|
+
var _a, userCopy, _loop_3, this_3, i, i, sub, _loop_4, this_4, j;
|
|
218
243
|
return __generator(this, function (_b) {
|
|
219
244
|
switch (_b.label) {
|
|
220
245
|
case 0:
|
|
@@ -223,14 +248,14 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
223
248
|
case 1:
|
|
224
249
|
_a._loggedInUsers = _b.sent();
|
|
225
250
|
userCopy = common_1.deepCopy(this._loggedInUsers);
|
|
226
|
-
|
|
251
|
+
_loop_3 = function (i) {
|
|
227
252
|
var loggedInUser = userCopy[i];
|
|
228
253
|
if (!loggedInUser.date || moment().diff(moment(loggedInUser.date), 'seconds') >= 30) {
|
|
229
|
-
if (
|
|
230
|
-
|
|
254
|
+
if (this_3._mainServer.getWS(loggedInUser.id_ws)) {
|
|
255
|
+
this_3.unsubscribeAll(this_3._mainServer.getWS(loggedInUser.id_ws));
|
|
231
256
|
}
|
|
232
257
|
else {
|
|
233
|
-
|
|
258
|
+
this_3._subscriptions.forEach(function (sub) {
|
|
234
259
|
for (var j = sub.clients.length - 1; j >= 0; j--) {
|
|
235
260
|
var client = sub.clients[j];
|
|
236
261
|
if (client.id_socket === loggedInUser.id_ws) {
|
|
@@ -239,27 +264,27 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
239
264
|
}
|
|
240
265
|
});
|
|
241
266
|
logged_in_users_collection_1.LoggedInUsers.deleteOne({ _id: loggedInUser._id });
|
|
242
|
-
if (
|
|
243
|
-
|
|
267
|
+
if (this_3._loggedInUsers.findIndex(function (a) { return a._id === loggedInUser._id; }) >= 0) {
|
|
268
|
+
this_3._loggedInUsers.splice(this_3._loggedInUsers.findIndex(function (a) { return a._id === loggedInUser._id; }), 1);
|
|
244
269
|
}
|
|
245
270
|
}
|
|
246
271
|
}
|
|
247
272
|
};
|
|
248
|
-
|
|
273
|
+
this_3 = this;
|
|
249
274
|
for (i = this._loggedInUsers.length - 1; i >= 0; i--) {
|
|
250
|
-
|
|
275
|
+
_loop_3(i);
|
|
251
276
|
}
|
|
252
277
|
for (i = 0; i < this._subscriptions.length; i++) {
|
|
253
278
|
sub = this._subscriptions[i];
|
|
254
|
-
|
|
279
|
+
_loop_4 = function (j) {
|
|
255
280
|
var client = sub.clients[j];
|
|
256
|
-
if (!
|
|
281
|
+
if (!this_4._loggedInUsers.some(function (a) { return a.id_ws === client.id_socket; })) {
|
|
257
282
|
sub.clients.splice(j, 1);
|
|
258
283
|
}
|
|
259
284
|
};
|
|
260
|
-
|
|
285
|
+
this_4 = this;
|
|
261
286
|
for (j = sub.clients.length - 1; j >= 0; j--) {
|
|
262
|
-
|
|
287
|
+
_loop_4(j);
|
|
263
288
|
}
|
|
264
289
|
}
|
|
265
290
|
return [2 /*return*/];
|
|
@@ -319,27 +344,20 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
319
344
|
// });
|
|
320
345
|
}
|
|
321
346
|
};
|
|
322
|
-
SubscriptionManager.prototype.invalidatePubsCache = function (collection, type
|
|
323
|
-
if (addToQueue === void 0) { addToQueue = true; }
|
|
347
|
+
SubscriptionManager.prototype.invalidatePubsCache = function (collection, type) {
|
|
324
348
|
// let startDate = new Date();
|
|
325
349
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(collection);
|
|
326
350
|
var collSubs = this._subscriptions.filter(function (a) { return a.collections.includes(collection); });
|
|
327
351
|
for (var i = collSubs.length - 1; i >= 0; i--) {
|
|
328
352
|
var sub = collSubs[i];
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
collection: collection,
|
|
338
|
-
subscription: sub,
|
|
339
|
-
running: false,
|
|
340
|
-
run_again: false
|
|
341
|
-
});
|
|
342
|
-
}
|
|
353
|
+
this.addToQueue({
|
|
354
|
+
_id: 0,
|
|
355
|
+
type: type,
|
|
356
|
+
collection: collection,
|
|
357
|
+
subscription: sub,
|
|
358
|
+
running: false,
|
|
359
|
+
run_again: false
|
|
360
|
+
});
|
|
343
361
|
}
|
|
344
362
|
// let endDate = new Date();
|
|
345
363
|
// this.currentPerfomanceMonitor.push({
|
|
@@ -442,7 +460,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
442
460
|
messageId: messageId,
|
|
443
461
|
id_socket: ws['id_socket']
|
|
444
462
|
}],
|
|
445
|
-
cacheId: 0
|
|
463
|
+
cacheId: 0,
|
|
464
|
+
next_run: null
|
|
446
465
|
});
|
|
447
466
|
if (publication === 'userWithId' && subscriptionData[0] !== ws['id_user']) {
|
|
448
467
|
this._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'SENDING INCORRECT USER FOR USERWITHID - 5!! Sub : ' + JSON.stringify(this._subscriptions[this._subscriptions.length - 1], null, 2) + ', Socket User: ' + ws['id_user'] + ', All Subs: ' + JSON.stringify(this._subscriptions, null, 2));
|
|
@@ -474,7 +493,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
474
493
|
// });
|
|
475
494
|
}
|
|
476
495
|
else if (sub_1.cacheId) {
|
|
477
|
-
this.
|
|
496
|
+
this.sendDataToOne(ws, messageId, sub_1, 'newSub', publication);
|
|
478
497
|
// let endDate = new Date();
|
|
479
498
|
// this.currentPerfomanceMonitor.push({
|
|
480
499
|
// _id: this.idPerformance++,
|
|
@@ -711,7 +730,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
711
730
|
});
|
|
712
731
|
};
|
|
713
732
|
// Fetch pub once, send to all clients linked to this pub
|
|
714
|
-
SubscriptionManager.prototype.
|
|
733
|
+
SubscriptionManager.prototype.sendDataToOne = function (ws, messageId, subscription, type, collection) {
|
|
715
734
|
var _this = this;
|
|
716
735
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
717
736
|
var cacheData, serverRes;
|
|
@@ -748,7 +767,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
748
767
|
// let endDate = new Date();
|
|
749
768
|
// this.currentPerfomanceMonitor.push({
|
|
750
769
|
// _id: this.idPerformance++,
|
|
751
|
-
// function: '
|
|
770
|
+
// function: 'sendDataToOne',
|
|
752
771
|
// publication: subscription.publication,
|
|
753
772
|
// // subscriptionData: subscription.subscriptionData,
|
|
754
773
|
// subscriptionData: [],
|
|
@@ -760,13 +779,13 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
760
779
|
resolve(true);
|
|
761
780
|
}
|
|
762
781
|
else {
|
|
763
|
-
this._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During
|
|
782
|
+
this._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During sendDataToOne - No Cache! - ' + subscription.publication + '\n\nData \n' + JSON.stringify(subscription.subscriptionData, null, 2));
|
|
764
783
|
resolve(false);
|
|
765
784
|
}
|
|
766
785
|
}
|
|
767
786
|
else { // Pub is different for each user (Look at users publication) [MUCH SLOWER, RE-RUNS FOR EACH USER]
|
|
768
787
|
(_a = this._publications[subscription.publication].function).call.apply(_a, __spreadArrays([Object.assign({}, this, SubscriptionManager.prototype), ws['id_user']], subscription.subscriptionData)).catch(function (methodErrs) {
|
|
769
|
-
_this._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'Error Detected During Subscription ' + subscription.publication + ' - (
|
|
788
|
+
_this._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'Error Detected During Subscription ' + subscription.publication + ' - (sendDataToOne - WS)\n\nData \n' + JSON.stringify(subscription.subscriptionData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
|
|
770
789
|
})
|
|
771
790
|
.then(function (res) {
|
|
772
791
|
var serverRes = {
|
|
@@ -782,7 +801,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
782
801
|
// let endDate = new Date();
|
|
783
802
|
// this.currentPerfomanceMonitor.push({
|
|
784
803
|
// _id: this.idPerformance++,
|
|
785
|
-
// function: '
|
|
804
|
+
// function: 'sendDataToOne',
|
|
786
805
|
// publication: subscription.publication,
|
|
787
806
|
// // subscriptionData: subscription.subscriptionData,
|
|
788
807
|
// subscriptionData: [],
|
|
@@ -808,33 +827,38 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
808
827
|
}); });
|
|
809
828
|
};
|
|
810
829
|
// Fetch pub once, send to all clients linked to this pub
|
|
811
|
-
SubscriptionManager.prototype.
|
|
830
|
+
SubscriptionManager.prototype.sendDataToAll = function (mongoQueue) {
|
|
812
831
|
var _this = this;
|
|
813
832
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
814
833
|
var _a;
|
|
815
834
|
var _this = this;
|
|
816
835
|
return __generator(this, function (_b) {
|
|
817
836
|
// let startDate = new Date();
|
|
818
|
-
if (!subscription.clients.length) {
|
|
819
|
-
if (subscription.cacheId) {
|
|
820
|
-
this._nodeCache.del(subscription.cacheId);
|
|
837
|
+
if (!mongoQueue.subscription.clients.length) {
|
|
838
|
+
if (mongoQueue.subscription.cacheId) {
|
|
839
|
+
this._nodeCache.del(mongoQueue.subscription.cacheId);
|
|
840
|
+
}
|
|
841
|
+
if (this._subscriptions.findIndex(function (a) { return a.publication === mongoQueue.subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(mongoQueue.subscription.subscriptionData); }) >= 0) {
|
|
842
|
+
this._subscriptions.splice(this._subscriptions.findIndex(function (a) { return a.publication === mongoQueue.subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(mongoQueue.subscription.subscriptionData); }), 1);
|
|
821
843
|
}
|
|
822
|
-
this._subscriptions.splice(this._subscriptions.findIndex(function (a) { return a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData); }), 1);
|
|
823
844
|
resolve(false);
|
|
824
845
|
}
|
|
825
846
|
else {
|
|
826
|
-
if (subscription.publication !== 'superadminAPM' && subscription.publication !== 'loggedInUsers') {
|
|
827
|
-
this._mainServer.getMethodManager().callMethodInternal.call(this._mainServer.getMethodManager(), 'insertSubscriptionLog', type, subscription.publication, collection, JSON.stringify(subscription.subscriptionData));
|
|
847
|
+
if (mongoQueue.subscription.publication !== 'superadminAPM' && mongoQueue.subscription.publication !== 'loggedInUsers') {
|
|
848
|
+
this._mainServer.getMethodManager().callMethodInternal.call(this._mainServer.getMethodManager(), 'insertSubscriptionLog', mongoQueue.type, mongoQueue.subscription.publication, mongoQueue.collection, JSON.stringify(mongoQueue.subscription.subscriptionData));
|
|
828
849
|
}
|
|
829
|
-
(_a = this._publications[subscription.publication].function).call.apply(_a, __spreadArrays([Object.assign({}, this, SubscriptionManager.prototype)], subscription.subscriptionData)).catch(function (methodErrs) {
|
|
830
|
-
_this._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'Error Detected During Subscription ' + subscription.publication + ' - (sendPubData)\n\nData \n' + JSON.stringify(subscription.subscriptionData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
|
|
850
|
+
(_a = this._publications[mongoQueue.subscription.publication].function).call.apply(_a, __spreadArrays([Object.assign({}, this, SubscriptionManager.prototype)], mongoQueue.subscription.subscriptionData)).catch(function (methodErrs) {
|
|
851
|
+
_this._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'Error Detected During Subscription ' + mongoQueue.subscription.publication + ' - (sendPubData)\n\nData \n' + JSON.stringify(mongoQueue.subscription.subscriptionData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
|
|
831
852
|
})
|
|
832
853
|
.then(function (res) {
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
854
|
+
mongoQueue.subscription.next_run = moment().add(1, 'second').toDate();
|
|
855
|
+
if (!mongoQueue.subscription.clients.length) {
|
|
856
|
+
if (mongoQueue.subscription.cacheId) {
|
|
857
|
+
_this._nodeCache.del(mongoQueue.subscription.cacheId);
|
|
858
|
+
}
|
|
859
|
+
if (_this._subscriptions.findIndex(function (a) { return a.publication === mongoQueue.subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(mongoQueue.subscription.subscriptionData); }) >= 0) {
|
|
860
|
+
_this._subscriptions.splice(_this._subscriptions.findIndex(function (a) { return a.publication === mongoQueue.subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(mongoQueue.subscription.subscriptionData); }), 1);
|
|
836
861
|
}
|
|
837
|
-
_this._subscriptions.splice(_this._subscriptions.findIndex(function (a) { return a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData); }), 1);
|
|
838
862
|
// let endDate = new Date();
|
|
839
863
|
// this.currentPerfomanceMonitor.push({
|
|
840
864
|
// _id: this.idPerformance++,
|
|
@@ -850,8 +874,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
850
874
|
resolve(false);
|
|
851
875
|
}
|
|
852
876
|
else {
|
|
853
|
-
if (!subscription.cacheId || _this._nodeCache.get(subscription.cacheId) !== JSON.stringify(res)) {
|
|
854
|
-
subscription.clients.forEach(function (client) {
|
|
877
|
+
if (!mongoQueue.subscription.cacheId || _this._nodeCache.get(mongoQueue.subscription.cacheId) !== JSON.stringify(res)) {
|
|
878
|
+
mongoQueue.subscription.clients.forEach(function (client) {
|
|
855
879
|
var ws = _this._mainServer.getWS(client.id_socket);
|
|
856
880
|
if (ws) {
|
|
857
881
|
var serverRes = {
|
|
@@ -859,8 +883,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
859
883
|
hasError: false,
|
|
860
884
|
data: res
|
|
861
885
|
};
|
|
862
|
-
if (subscription.publication === 'userWithId' && client.id_user !== ws['id_user']) {
|
|
863
|
-
_this._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'SENDING INCORRECT USER FOR USERWITHID!! Client User: ' + client.id_user + ', Socket User: ' + ws['id_user'] + ', Sub: ' + JSON.stringify(subscription, null, 2) + ', All Subs: ' + JSON.stringify(_this._subscriptions, null, 2));
|
|
886
|
+
if (mongoQueue.subscription.publication === 'userWithId' && client.id_user !== ws['id_user']) {
|
|
887
|
+
_this._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'SENDING INCORRECT USER FOR USERWITHID!! Client User: ' + client.id_user + ', Socket User: ' + ws['id_user'] + ', Sub: ' + JSON.stringify(mongoQueue.subscription, null, 2) + ', All Subs: ' + JSON.stringify(_this._subscriptions, null, 2));
|
|
864
888
|
}
|
|
865
889
|
_this.sendWS(ws, serverRes);
|
|
866
890
|
}
|
|
@@ -878,15 +902,15 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
878
902
|
break;
|
|
879
903
|
}
|
|
880
904
|
}
|
|
881
|
-
console.log('Sub Cache: ' + 'Too Big - ' + subscription.publication + ' - Deleted: ' + deleteCount + ' - ' + nodeCacheSize);
|
|
905
|
+
console.log('Sub Cache: ' + 'Too Big - ' + mongoQueue.subscription.publication + ' - Deleted: ' + deleteCount + ' - ' + nodeCacheSize);
|
|
882
906
|
}
|
|
883
|
-
if (subscription.cacheId) {
|
|
884
|
-
_this._nodeCache.del(subscription.cacheId);
|
|
907
|
+
if (mongoQueue.subscription.cacheId) {
|
|
908
|
+
_this._nodeCache.del(mongoQueue.subscription.cacheId);
|
|
885
909
|
}
|
|
886
910
|
var cacheId = _this._cacheId;
|
|
887
911
|
_this._cacheId += 1;
|
|
888
912
|
_this._nodeCache.set(cacheId, JSON.stringify(res));
|
|
889
|
-
subscription.cacheId = cacheId;
|
|
913
|
+
mongoQueue.subscription.cacheId = cacheId;
|
|
890
914
|
// let endDate = new Date();
|
|
891
915
|
// this.currentPerfomanceMonitor.push({
|
|
892
916
|
// _id: this.idPerformance++,
|
|
@@ -903,7 +927,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
903
927
|
resolve(true);
|
|
904
928
|
}
|
|
905
929
|
}, function (err) {
|
|
906
|
-
subscription.clients.forEach(function (client) {
|
|
930
|
+
mongoQueue.subscription.clients.forEach(function (client) {
|
|
907
931
|
var ws = _this._mainServer.getWS(client.id_socket);
|
|
908
932
|
if (ws) {
|
|
909
933
|
if (ws['id_socket'] === client.id_socket) {
|