@resolveio/server-lib 5.0.14 → 5.0.15
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 +75 -22
- package/package.json +1 -1
|
@@ -674,26 +674,79 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
674
674
|
}); }, 500);
|
|
675
675
|
};
|
|
676
676
|
SubscriptionManager.prototype.resendPubsForDelete = function (collection) {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
if (ws['id_socket'] === client.id_socket) {
|
|
689
|
-
that.sendPubDataOnce(ws, client.messageId, sub, 'delete', collection);
|
|
677
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
678
|
+
var that, jj, _loop_5, zz;
|
|
679
|
+
return __generator(this, function (_a) {
|
|
680
|
+
switch (_a.label) {
|
|
681
|
+
case 0:
|
|
682
|
+
that = this;
|
|
683
|
+
for (jj = this._subCache.length - 1; jj >= 0; jj--) {
|
|
684
|
+
if (this._subCache[jj].collection === collection) {
|
|
685
|
+
this._nodeCache.del(this._subCache[jj].id);
|
|
686
|
+
this._subCache.splice(jj, 1);
|
|
687
|
+
}
|
|
690
688
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
689
|
+
_loop_5 = function (zz) {
|
|
690
|
+
var sub;
|
|
691
|
+
return __generator(this, function (_a) {
|
|
692
|
+
switch (_a.label) {
|
|
693
|
+
case 0:
|
|
694
|
+
sub = that._subscriptions.filter(function (a) { return a.collections.includes(collection); })[zz];
|
|
695
|
+
if (!that._publications[sub.publication].ws_specific) return [3 /*break*/, 4];
|
|
696
|
+
if (!sub.clients.length) return [3 /*break*/, 1];
|
|
697
|
+
sub.clients.forEach(function (client) {
|
|
698
|
+
that._wss.clients.forEach(function (ws) {
|
|
699
|
+
if (ws['id_socket'] === client.id_socket) {
|
|
700
|
+
that.sendPubDataOnce(ws, client.messageId, sub, 'delete', collection);
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
});
|
|
704
|
+
return [3 /*break*/, 3];
|
|
705
|
+
case 1:
|
|
706
|
+
that._subscriptions.splice(that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
707
|
+
return [4 /*yield*/, active_subscription_collection_1.ActiveSubscriptions.deleteOne({
|
|
708
|
+
$and: [
|
|
709
|
+
{ publication: sub.publication },
|
|
710
|
+
{ subData: JSON.stringify(sub.subscriptionData) }
|
|
711
|
+
]
|
|
712
|
+
}).exec()];
|
|
713
|
+
case 2:
|
|
714
|
+
_a.sent();
|
|
715
|
+
_a.label = 3;
|
|
716
|
+
case 3: return [3 /*break*/, 7];
|
|
717
|
+
case 4:
|
|
718
|
+
if (!!sub.clients.length) return [3 /*break*/, 6];
|
|
719
|
+
that._subscriptions.splice(that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
720
|
+
return [4 /*yield*/, active_subscription_collection_1.ActiveSubscriptions.deleteOne({
|
|
721
|
+
$and: [
|
|
722
|
+
{ publication: sub.publication },
|
|
723
|
+
{ subData: JSON.stringify(sub.subscriptionData) }
|
|
724
|
+
]
|
|
725
|
+
}).exec()];
|
|
726
|
+
case 5:
|
|
727
|
+
_a.sent();
|
|
728
|
+
return [3 /*break*/, 7];
|
|
729
|
+
case 6:
|
|
730
|
+
that.sendPubData(sub, 'delete', collection);
|
|
731
|
+
_a.label = 7;
|
|
732
|
+
case 7: return [2 /*return*/];
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
};
|
|
736
|
+
zz = that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).length - 1;
|
|
737
|
+
_a.label = 1;
|
|
738
|
+
case 1:
|
|
739
|
+
if (!(zz >= 0)) return [3 /*break*/, 4];
|
|
740
|
+
return [5 /*yield**/, _loop_5(zz)];
|
|
741
|
+
case 2:
|
|
742
|
+
_a.sent();
|
|
743
|
+
_a.label = 3;
|
|
744
|
+
case 3:
|
|
745
|
+
zz--;
|
|
746
|
+
return [3 /*break*/, 1];
|
|
747
|
+
case 4: return [2 /*return*/];
|
|
748
|
+
}
|
|
749
|
+
});
|
|
697
750
|
});
|
|
698
751
|
};
|
|
699
752
|
// Document: Inserted/Modified/Deleted Document
|
|
@@ -701,12 +754,12 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
701
754
|
// Check to see if any pubs need to refetch due to Mongo operation
|
|
702
755
|
SubscriptionManager.prototype.checkPubsForChanges = function (collection, document, type) {
|
|
703
756
|
return __awaiter(this, void 0, void 0, function () {
|
|
704
|
-
var that,
|
|
757
|
+
var that, _loop_6, this_1, i;
|
|
705
758
|
return __generator(this, function (_a) {
|
|
706
759
|
switch (_a.label) {
|
|
707
760
|
case 0:
|
|
708
761
|
that = this;
|
|
709
|
-
|
|
762
|
+
_loop_6 = function (i) {
|
|
710
763
|
var _a, _b, sub, removed, _c, _d, removed, removed, removed;
|
|
711
764
|
return __generator(this, function (_e) {
|
|
712
765
|
switch (_e.label) {
|
|
@@ -841,7 +894,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
841
894
|
_a.label = 1;
|
|
842
895
|
case 1:
|
|
843
896
|
if (!(i >= 0)) return [3 /*break*/, 4];
|
|
844
|
-
return [5 /*yield**/,
|
|
897
|
+
return [5 /*yield**/, _loop_6(i)];
|
|
845
898
|
case 2:
|
|
846
899
|
_a.sent();
|
|
847
900
|
_a.label = 3;
|