From 4af1fd2a79bb2c816a577aecf8e9752cade91e2d Mon Sep 17 00:00:00 2001 From: Pierre Moreau Date: Mon, 2 Feb 2015 14:56:15 -0800 Subject: [PATCH] Aphlict - remove listeners when clients close the connection Summary: Ref T7110. Listeners are now removed when clients close the connection to avoid stacking a never ending number of unused listeners. Test Plan: Using `wscat` to connect to the Aphlict server; when closing the connection a 'Diconnected.' will appear in the logs and the number of active listeners is decreased by one. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T7110 Differential Revision: https://secure.phabricator.com/D11634 --- support/aphlict/server/lib/AphlictClientServer.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/support/aphlict/server/lib/AphlictClientServer.js b/support/aphlict/server/lib/AphlictClientServer.js index 4ee6be0054..b8a903f226 100644 --- a/support/aphlict/server/lib/AphlictClientServer.js +++ b/support/aphlict/server/lib/AphlictClientServer.js @@ -69,6 +69,11 @@ JX.install('AphlictClientServer', { } }); + ws.on('close', function() { + self.getListenerList().removeListener(listener); + log('Disconnected.'); + }); + wss.on('close', function() { self.getListenerList().removeListener(listener); log('Disconnected.');