summaryrefslogtreecommitdiff
path: root/kvmd/apps
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-04-12 06:26:38 +0300
committerMaxim Devaev <[email protected]>2022-04-12 06:31:22 +0300
commit1e5c8535f6a30629381b08ccfae1fc4668955ba8 (patch)
tree0892ce9341d0810bad4381809c3ceb3d07942892 /kvmd/apps
parent80b5546d21cb5c67aeb4f28f339fa4a029bc88c2 (diff)
refactoring
Diffstat (limited to 'kvmd/apps')
-rw-r--r--kvmd/apps/kvmd/server.py18
1 files changed, 2 insertions, 16 deletions
diff --git a/kvmd/apps/kvmd/server.py b/kvmd/apps/kvmd/server.py
index f40381a9..aa643d9f 100644
--- a/kvmd/apps/kvmd/server.py
+++ b/kvmd/apps/kvmd/server.py
@@ -57,7 +57,7 @@ from ...htserver import make_json_response
from ...htserver import make_json_exception
from ...htserver import send_ws_event
from ...htserver import broadcast_ws_event
-from ...htserver import parse_ws_event
+from ...htserver import process_ws_messages
from ...htserver import HttpServer
from ...plugins import BasePlugin
@@ -278,21 +278,7 @@ class KvmdServer(HttpServer): # pylint: disable=too-many-arguments,too-many-ins
])
await send_ws_event(ws, "loop", {})
-
- async for msg in ws:
- if msg.type != aiohttp.web.WSMsgType.TEXT:
- break
- try:
- (event_type, event) = parse_ws_event(msg.data)
- except Exception as err:
- get_logger(0).error("Can't parse JSON event from websocket: %r", err)
- else:
- handler = self.__ws_handlers.get(event_type)
- if handler:
- await handler(ws, event)
- else:
- get_logger(0).error("Unknown websocket event: %r", msg.data)
-
+ await process_ws_messages(ws, self.__ws_handlers)
return ws
finally:
await self.__remove_ws_client(client)