summaryrefslogtreecommitdiff
path: root/kvmd/apps/vnc/server.py
diff options
context:
space:
mode:
Diffstat (limited to 'kvmd/apps/vnc/server.py')
-rw-r--r--kvmd/apps/vnc/server.py71
1 files changed, 33 insertions, 38 deletions
diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py
index 366a4a91..2bf6e79e 100644
--- a/kvmd/apps/vnc/server.py
+++ b/kvmd/apps/vnc/server.py
@@ -128,8 +128,6 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
self.__mouse_buttons: dict[str, (bool | None)] = dict.fromkeys(["left", "right", "middle"], None)
self.__mouse_move = {"x": -1, "y": -1}
- self.__lock = asyncio.Lock()
-
self.__modifiers = 0
# =====
@@ -179,15 +177,13 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
else:
if isinstance(host, str):
name = f"PiKVM: {host}"
- async with self.__lock:
- if self._encodings.has_rename:
- await self._send_rename(name)
+ if self._encodings.has_rename:
+ await self._send_rename(name)
self.__shared_params.name = name
elif event_type == "hid_state":
- async with self.__lock:
- if self._encodings.has_leds_state:
- await self._send_leds_state(**event["keyboard"]["leds"])
+ if self._encodings.has_leds_state:
+ await self._send_leds_state(**event["keyboard"]["leds"])
# =====
@@ -274,38 +270,37 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
if self.__fb_queue.qsize() == 0:
break
- async with self.__lock:
- if self._width != last["width"] or self._height != last["height"]:
- self.__shared_params.width = last["width"]
- self.__shared_params.height = last["height"]
- if not self._encodings.has_resize:
- msg = (
- f"Resoultion changed: {self._width}x{self._height}"
- f" -> {last['width']}x{last['height']}\nPlease reconnect"
- )
- await self._send_fb_jpeg((await self.__make_text_frame(msg))["data"])
- continue
- await self._send_resize(last["width"], last["height"])
-
- if len(last["data"]) == 0:
- # Вдруг какой-то баг
- await self._send_fb_allow_again()
+ if self._width != last["width"] or self._height != last["height"]:
+ self.__shared_params.width = last["width"]
+ self.__shared_params.height = last["height"]
+ if not self._encodings.has_resize:
+ msg = (
+ f"Resoultion changed: {self._width}x{self._height}"
+ f" -> {last['width']}x{last['height']}\nPlease reconnect"
+ )
+ await self._send_fb_jpeg((await self.__make_text_frame(msg))["data"])
continue
-
- if last["format"] == StreamFormats.JPEG:
- await self._send_fb_jpeg(last["data"])
- elif last["format"] == StreamFormats.H264:
- if not self._encodings.has_h264:
- raise RfbError("The client doesn't want to accept H264 anymore")
- if has_h264_key:
- self.__fb_key_required = False
- await self._send_fb_h264(last["data"])
- else:
- self.__fb_key_required = True
- await self._send_fb_allow_again()
+ await self._send_resize(last["width"], last["height"])
+
+ if len(last["data"]) == 0:
+ # Вдруг какой-то баг
+ await self._send_fb_allow_again()
+ continue
+
+ if last["format"] == StreamFormats.JPEG:
+ await self._send_fb_jpeg(last["data"])
+ elif last["format"] == StreamFormats.H264:
+ if not self._encodings.has_h264:
+ raise RfbError("The client doesn't want to accept H264 anymore")
+ if has_h264_key:
+ self.__fb_key_required = False
+ await self._send_fb_h264(last["data"])
else:
- raise RuntimeError(f"Unknown format: {last['format']}")
- last["data"] = b""
+ self.__fb_key_required = True
+ await self._send_fb_allow_again()
+ else:
+ raise RuntimeError(f"Unknown format: {last['format']}")
+ last["data"] = b""
# =====