diff options
author | Maxim Devaev <[email protected]> | 2022-07-19 16:42:46 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2022-07-19 16:42:46 +0300 |
commit | adf4be9bf7c3b04fde04a6f3e516e48c5ea1a1e6 (patch) | |
tree | d36c60db2a833436937243240cbd6331e987a42a /kvmd/apps | |
parent | b16359c53e5dd62839a9af0fa14bdb9c5f350c75 (diff) |
common event parsing
Diffstat (limited to 'kvmd/apps')
-rw-r--r-- | kvmd/apps/vnc/server.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py index 49d0c81f..64113c11 100644 --- a/kvmd/apps/vnc/server.py +++ b/kvmd/apps/vnc/server.py @@ -164,16 +164,16 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes async with self.__kvmd_session.ws() as self.__kvmd_ws: logger.info("[kvmd] %s: Connected to KVMD websocket", self._remote) self.__stage3_ws_connected.set_passed() - async for event in self.__kvmd_ws.communicate(): - await self.__process_ws_event(event) + async for (event_type, event) in self.__kvmd_ws.communicate(): + await self.__process_ws_event(event_type, event) raise RfbError("KVMD closed the websocket (the server may have been stopped)") finally: self.__kvmd_ws = None - async def __process_ws_event(self, event: Dict) -> None: - if event["event_type"] == "info_meta_state": + async def __process_ws_event(self, event_type: str, event: Dict) -> None: + if event_type == "info_meta_state": try: - host = event["event"]["server"]["host"] + host = event["server"]["host"] except Exception: host = None else: @@ -184,10 +184,10 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes await self._send_rename(name) self.__shared_params.name = name - elif event["event_type"] == "hid_state": + elif event_type == "hid_state": async with self.__lock: if self._encodings.has_leds_state: - await self._send_leds_state(**event["event"]["keyboard"]["leds"]) + await self._send_leds_state(**event["keyboard"]["leds"]) # ===== |