From 1fc8aa45058e25cc10539988609981c7c0ab6980 Mon Sep 17 00:00:00 2001 From: Samuel Sloniker Date: Fri, 9 Jul 2021 18:47:29 -0700 Subject: [PATCH] Add connect() and disconnect() to backend API --- server/backends/port8080.py | 8 ++++++++ server/backends/x11.py | 8 ++++++++ server/wss.py | 3 +++ 3 files changed, 19 insertions(+) diff --git a/server/backends/port8080.py b/server/backends/port8080.py index ea5bfd5..bd8ca28 100644 --- a/server/backends/port8080.py +++ b/server/backends/port8080.py @@ -12,3 +12,11 @@ def get_img(): def touch(x, y, is_long): requests.get(f'http://localhost:8080/set_touch?x={x}&y={y}&hold={1 if is_long else 0}') + + +def connect(): + pass + + +def disconnect(): + pass diff --git a/server/backends/x11.py b/server/backends/x11.py index a99c410..9667d6d 100644 --- a/server/backends/x11.py +++ b/server/backends/x11.py @@ -25,3 +25,11 @@ def touch(x, y, is_long): threading.Thread(target=_long_touch, args=(x, y,)).start() else: subprocess.run(['xdotool', 'mousemove', str(x), str(y), 'click', '1']) + + +def connect(): + pass + + +def disconnect(): + pass diff --git a/server/wss.py b/server/wss.py index 74d0e45..b1c56b8 100644 --- a/server/wss.py +++ b/server/wss.py @@ -83,6 +83,7 @@ class HCRAServer(tornado.websocket.WebSocketHandler): self.client.good = None client = None self.is_open = False + imgproc.backend.disconnect() def on_message(self, message): action = message.split(' ', 1)[0] @@ -112,6 +113,8 @@ class HCRAServer(tornado.websocket.WebSocketHandler): except DisconnectError as e: self.write_message(str(e)) return + + imgproc.backend.connect() try: imgname = imgproc.get_full_img()