From ad3ed1e626b0ae7a4ec7eb5faf50692cd1fd63e2 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sat, 27 Feb 2021 00:01:21 +0100 Subject: [PATCH] disconnect clients if the max_clients setting is lowered --- owrx/client.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/owrx/client.py b/owrx/client.py index f992e45..f58165d 100644 --- a/owrx/client.py +++ b/owrx/client.py @@ -23,6 +23,7 @@ class ClientRegistry(object): def __init__(self): self.clients = [] + Config.get().wireProperty("max_clients", self._checkClientCount) super().__init__() def broadcast(self): @@ -46,3 +47,9 @@ class ClientRegistry(object): except ValueError: pass self.broadcast() + + def _checkClientCount(self, new_count): + logger.debug("new client count: %i", new_count) + for client in self.clients[new_count:]: + logger.debug("closing one connection...") + client.close()