Move responsibility of handling unsubscription on close

Notify the SubscriptionController that a connection closed from the
Connection instead of having the subscription controller set up an event
to do so.  This simplifies the logic on the SubscriptionController's
side.
This commit is contained in:
Hornwitser committed 2023-12-11 21:47:15 +01:00
1 parent 0df672ecca
commit 1d729adbb7
3 files changed
+39 -17

No files matched your search

+18
View File
@@ -243,6 +243,24 @@ describe("lib/subscriptions", function() {
});
});
describe("unsubscribe()", function() {
beforeEach(function() {
subscriptions.handle(RegisteredEvent);
for (let connectorData of connectorSetupDate) {
subscriptions._handleRequest(connectorData.request, connectorData.src, connectorData.dst);
}
});
it("should remove an active subscription", async function() {
const link = mockController.wsServer.controlConnections.get(0);
subscriptions.unsubscribe(link);
subscriptions.broadcast(new RegisteredEvent());
await onceConnectorSend(1);
assertNoEvent(0);
assertLastEvent(1, RegisteredEvent);
});
});
describe("_handleRequest()", function() {
beforeEach(function() {
subscriptions.handle(RegisteredEvent);