diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2024-04-13 23:02:00 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2024-04-14 17:31:03 +0200 |
commit | 784af6cab0bc195c5c53a6f08bd30fda1f15f977 (patch) | |
tree | 9572e897dcc1434fb1b012accf3eb28844d587aa /macropad.pyw | |
parent | 89d3bb2421a42dccd4f159b77e9f7fb103a4f8b8 (diff) |
Reconnect quicker after a deconnection
Diffstat (limited to 'macropad.pyw')
-rwxr-xr-x | macropad.pyw | 9 |
1 files changed, 6 insertions, 3 deletions
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) )) |