@resolveio/server-lib 5.2.28 → 5.2.29
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/subscription.manager.js +32 -11
- package/package.json +1 -1
|
@@ -128,15 +128,38 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
128
128
|
logged_in_users_collection_1.LoggedInUsers.find().then(function (loggedInUsers) {
|
|
129
129
|
_this._loggedInUsers = loggedInUsers;
|
|
130
130
|
});
|
|
131
|
-
setInterval(function () {
|
|
132
|
-
var userCopy
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
132
|
+
var userCopy, i, loggedInUser;
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
switch (_a.label) {
|
|
135
|
+
case 0:
|
|
136
|
+
userCopy = common_1.deepCopy(this._loggedInUsers);
|
|
137
|
+
i = this._loggedInUsers.length - 1;
|
|
138
|
+
_a.label = 1;
|
|
139
|
+
case 1:
|
|
140
|
+
if (!(i >= 0)) return [3 /*break*/, 7];
|
|
141
|
+
loggedInUser = userCopy[i];
|
|
142
|
+
if (!(!loggedInUser.updatedAt || moment().diff(moment(loggedInUser.updatedAt), 'minutes', true) > 1)) return [3 /*break*/, 6];
|
|
143
|
+
if (!this._mainServer.getWS(loggedInUser.id_ws)) return [3 /*break*/, 2];
|
|
144
|
+
this.unsubscribeAll(this._mainServer.getWS(loggedInUser.id_ws));
|
|
145
|
+
return [3 /*break*/, 6];
|
|
146
|
+
case 2: return [4 /*yield*/, logged_in_users_collection_1.LoggedInUsers.findById(loggedInUser._id)];
|
|
147
|
+
case 3:
|
|
148
|
+
if (!_a.sent()) return [3 /*break*/, 5];
|
|
149
|
+
return [4 /*yield*/, logged_in_users_collection_1.LoggedInUsers.deleteOne({ _id: loggedInUser._id }).exec()];
|
|
150
|
+
case 4:
|
|
151
|
+
_a.sent();
|
|
152
|
+
_a.label = 5;
|
|
153
|
+
case 5:
|
|
154
|
+
this._loggedInUsers.splice(i, 1);
|
|
155
|
+
_a.label = 6;
|
|
156
|
+
case 6:
|
|
157
|
+
i--;
|
|
158
|
+
return [3 /*break*/, 1];
|
|
159
|
+
case 7: return [2 /*return*/];
|
|
137
160
|
}
|
|
138
|
-
}
|
|
139
|
-
}, 60000);
|
|
161
|
+
});
|
|
162
|
+
}); }, 60000);
|
|
140
163
|
}
|
|
141
164
|
// Add all files to publications private object
|
|
142
165
|
SubscriptionManager.prototype.publications = function (method) {
|
|
@@ -351,7 +374,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
351
374
|
switch (_a.label) {
|
|
352
375
|
case 0:
|
|
353
376
|
that = this;
|
|
354
|
-
if (!ws) return [3 /*break*/, 3];
|
|
355
377
|
return [4 /*yield*/, logged_in_users_collection_1.LoggedInUsers.findOne({ id_ws: ws['id_socket'] })];
|
|
356
378
|
case 1:
|
|
357
379
|
loggedInUser = _a.sent();
|
|
@@ -395,8 +417,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
395
417
|
}
|
|
396
418
|
});
|
|
397
419
|
ws.terminate();
|
|
398
|
-
|
|
399
|
-
case 3: return [2 /*return*/];
|
|
420
|
+
return [2 /*return*/];
|
|
400
421
|
}
|
|
401
422
|
});
|
|
402
423
|
});
|