Add connect() and disconnect() to backend API

This commit is contained in:
Samuel Sloniker 2021-07-09 18:47:29 -07:00
parent 185e515c66
commit 1fc8aa4505
3 changed files with 19 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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()