diff options
| -rwxr-xr-x | interfaces/endpoint.py | 4 | ||||
| -rwxr-xr-x | macropad.pyw | 9 | ||||
| -rwxr-xr-x | socket_conn.py | 3 | 
3 files changed, 9 insertions, 7 deletions
| diff --git a/interfaces/endpoint.py b/interfaces/endpoint.py index 5aa369b..15356c2 100755 --- a/interfaces/endpoint.py +++ b/interfaces/endpoint.py @@ -82,7 +82,7 @@ class EndPoint(object):          try:
              received = self.connection.read()
          except Exception as e:
 -            print(e)
 +            print("fetch error", e)
              self.state = self.STATE_DISCONNECTED
              return
          else:
 @@ -108,5 +108,5 @@ class EndPoint(object):              j = json.dumps( data )
              self.connection.write(bytes(j, "utf-8"))
          except Exception as e:
 -            print(e)
 +            print("send error", e)
              self.state = self.STATE_DISCONNECTED
 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) )) diff --git a/socket_conn.py b/socket_conn.py index 4367240..6906c0b 100755 --- a/socket_conn.py +++ b/socket_conn.py @@ -51,5 +51,4 @@ class SocketConnection(object):      def write(self, content:str) -> None:
          """ Write into the connection.
              Raise an exception if disconnected """
 -        self.s.sendall(content)
 -        self.s.sendall(bytes("\n", "utf-8"))
 +        self.s.sendall(content + bytes("\n", "utf-8"))
 | 
