refactor: use websocket again

This commit is contained in:
2024-11-25 17:53:37 +00:00
parent b50190f67e
commit bd4827dd99
5 changed files with 240 additions and 61 deletions

19
listener_counter.py Normal file
View File

@@ -0,0 +1,19 @@
import threading
class ListenerCounter:
def __init__(self) -> None:
self.__listener = set()
self.__lock = threading.Lock()
def add_listener(self, listener_id: str):
with self.__lock:
self.__listener.add(listener_id)
def remove_listener(self, listener_id: str):
with self.__lock:
self.__listener.discard(listener_id)
def count(self) -> int:
with self.__lock:
return len(self.__listener)