diff --git a/minode/connection.py b/minode/connection.py index 2d057bb..405c010 100644 --- a/minode/connection.py +++ b/minode/connection.py @@ -491,4 +491,24 @@ class Connection(ConnectionBase): self.vectors_to_send.update(getdata.vectors) +class TrackingConnection(Connection): + """A helper to track number of servers in the network""" + def __init__(self, *args): + super().__init__(*args) + self.connected_time = None + self.active = False + + def _on_connection_fully_established(self): + self.connected_time = time.time() + super()._on_connection_fully_established() + + def _process_message(self, m): + super()._process_message(m) + if not self.active and m.command in (b'object', b'getdata'): + self.active = True + + # def run(self): + # super().run() + + shared.connection = Connection