From 784af6cab0bc195c5c53a6f08bd30fda1f15f977 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Sat, 13 Apr 2024 23:02:00 +0200 Subject: Reconnect quicker after a deconnection --- macropad.pyw | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'macropad.pyw') diff --git a/macropad.pyw b/macropad.pyw index 55bb1cf..87dfd40 100755 --- a/macropad.pyw +++ b/macropad.pyw @@ -191,8 +191,9 @@ class Application(object): return self.last_layout = data + conn = component.queryUtility(interfaces.endpoint.IEndpoint) if isinstance(data, dict): - component.queryUtility(interfaces.endpoint.IEndpoint).send(data) + conn.send(data) return elif isinstance(data, str): if not path.exists(data): @@ -203,7 +204,7 @@ class Application(object): j = json.loads(json_data) content = json.dumps(j) - component.queryUtility(interfaces.endpoint.IEndpoint).send(j) + conn.send(j) def associate(self, layout: str, name: str): mapping[name] = layout @@ -218,8 +219,10 @@ class Application(object): component.handle(Debug("Reconnecting…")) conn.state = conn.STATE_CONNECTING - self.window.after(5000, conn.connect) + self.window.after(1000, conn.connect) else: + # Check if we have something to read from the server, and by + # the by if the server is still active. conn.fetch() except Exception as e: component.handle(Debug( str(e) )) -- cgit v1.2.3