From d57905c73134ce31a295dddfa8c8fa97c290d928 Mon Sep 17 00:00:00 2001 From: Samuel Sloniker Date: Thu, 17 Jun 2021 14:52:23 -0700 Subject: [PATCH] Rearrange files again, and fix more bugs --- client/client.js | 6 ++++-- server/{ohcapi.py => backends/port8080.py} | 0 server/{hcapi.py => backends/x11.py} | 0 server/wss.py | 13 ++++++++++--- 4 files changed, 14 insertions(+), 5 deletions(-) rename server/{ohcapi.py => backends/port8080.py} (100%) rename server/{hcapi.py => backends/x11.py} (100%) diff --git a/client/client.js b/client/client.js index adeae91..62e766c 100644 --- a/client/client.js +++ b/client/client.js @@ -70,16 +70,18 @@ function touch(e) { click_timeout = setTimeout(function() { is_short = false }, 1000) + is_short = true } function release(e) { - clearTimeout(click_timeout) x = e.layerX y = e.layerY w = displayWidth - length = is_short?0:1 + length = is_short?false:true ws.send('touch ' + localStorage.getItem('password') + ' ' + x + ' ' + y + ' ' + w + ' ' + length) + clearTimeout(click_timeout) + is_short = true } diff --git a/server/ohcapi.py b/server/backends/port8080.py similarity index 100% rename from server/ohcapi.py rename to server/backends/port8080.py diff --git a/server/hcapi.py b/server/backends/x11.py similarity index 100% rename from server/hcapi.py rename to server/backends/x11.py diff --git a/server/wss.py b/server/wss.py index f981c07..e040aa8 100644 --- a/server/wss.py +++ b/server/wss.py @@ -1,6 +1,5 @@ import os import base64 -import hcapi import threading import logging import random @@ -10,11 +9,19 @@ import tempfile import queue from websocket_server import WebsocketServer + +# Select backend - backends.port8080 uses HamClock's port 8080 service; +# backends.x11 uses an X11 server (typically Xvfb) (make sure DISPLAY is set +# correctly!) + +#import backends.port8080 as hcapi +import backends.x11 as hcapi + + def cycle(): try: changed = hcapi.get_img() except Exception as e: - #server.send_message_to_all('err%noconn%Server failed to capture screenshot') for client in clients.values(): client.send('err%noconn%Server failed to capture screenshot', 'ERR') time.sleep(3) @@ -109,7 +116,7 @@ def do_touch(client, server, message): else: _, password, x, y, w, is_long = message.split(' ') if password == 'password': - x, y, w, is_long = int(x), int(y), int(w), bool(is_long) + x, y, w, is_long = int(x), int(y), int(w), is_long == 'true' hcapi.touch(x, y, w, is_long) else: clients[client['id']].send(f'badpass', 'BADPASS')