summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2025-01-05 15:19:04 +0200
committerMaxim Devaev <[email protected]>2025-01-05 15:19:04 +0200
commit4488365dfbbf7b35cd7b27f0392768e273cd271d (patch)
treefc91746f67bcfed4b62e10738ae07d6a08547db1
parent5a61ddecd3a6fadb71464cc32823e63a8009fb2b (diff)
removed _state suffix from all ws events
-rw-r--r--kvmd/apps/kvmd/server.py18
-rw-r--r--kvmd/apps/pst/server.py2
-rw-r--r--kvmd/apps/pstrun/__init__.py2
-rw-r--r--kvmd/apps/vnc/server.py4
-rw-r--r--kvmd/clients/pst.py2
-rw-r--r--web/share/js/kvm/session.js20
6 files changed, 24 insertions, 24 deletions
diff --git a/kvmd/apps/kvmd/server.py b/kvmd/apps/kvmd/server.py
index 17fd85d0..858ba1b6 100644
--- a/kvmd/apps/kvmd/server.py
+++ b/kvmd/apps/kvmd/server.py
@@ -131,15 +131,15 @@ class _Subsystem:
class KvmdServer(HttpServer): # pylint: disable=too-many-arguments,too-many-instance-attributes
- __EV_GPIO_STATE = "gpio_state"
- __EV_HID_STATE = "hid_state"
- __EV_HID_KEYMAPS_STATE = "hid_keymaps_state" # FIXME
- __EV_ATX_STATE = "atx_state"
- __EV_MSD_STATE = "msd_state"
- __EV_STREAMER_STATE = "streamer_state"
- __EV_OCR_STATE = "ocr_state"
- __EV_INFO_STATE = "info_state"
- __EV_SWITCH_STATE = "switch_state"
+ __EV_GPIO_STATE = "gpio"
+ __EV_HID_STATE = "hid"
+ __EV_HID_KEYMAPS_STATE = "hid_keymaps" # FIXME
+ __EV_ATX_STATE = "atx"
+ __EV_MSD_STATE = "msd"
+ __EV_STREAMER_STATE = "streamer"
+ __EV_OCR_STATE = "ocr"
+ __EV_INFO_STATE = "info"
+ __EV_SWITCH_STATE = "switch"
def __init__( # pylint: disable=too-many-arguments,too-many-locals
self,
diff --git a/kvmd/apps/pst/server.py b/kvmd/apps/pst/server.py
index d96043b3..ddeccc41 100644
--- a/kvmd/apps/pst/server.py
+++ b/kvmd/apps/pst/server.py
@@ -129,7 +129,7 @@ class PstServer(HttpServer): # pylint: disable=too-many-arguments,too-many-inst
await self.__notifier.wait()
async def __broadcast_storage_state(self, clients: int, write_allowed: bool) -> None:
- await self._broadcast_ws_event("storage_state", {
+ await self._broadcast_ws_event("storage", {
"clients": clients,
"data": {
"path": self.__data_path,
diff --git a/kvmd/apps/pstrun/__init__.py b/kvmd/apps/pstrun/__init__.py
index 33e1396e..d55835fd 100644
--- a/kvmd/apps/pstrun/__init__.py
+++ b/kvmd/apps/pstrun/__init__.py
@@ -84,7 +84,7 @@ async def _run_cmd_ws(cmd: list[str], ws: aiohttp.ClientWebSocketResponse) -> in
msg = receive_task.result()
if msg.type == aiohttp.WSMsgType.TEXT:
(event_type, event) = htserver.parse_ws_event(msg.data)
- if event_type == "storage_state":
+ if event_type == "storage":
if event["data"]["write_allowed"] and proc is None:
logger.info("PST write is allowed: %s", event["data"]["path"])
logger.info("Running the process ...")
diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py
index 6bb7caed..b2ae71fa 100644
--- a/kvmd/apps/vnc/server.py
+++ b/kvmd/apps/vnc/server.py
@@ -177,7 +177,7 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
self.__kvmd_ws = None
async def __process_ws_event(self, event_type: str, event: dict) -> None:
- if event_type == "info_state":
+ if event_type == "info":
if "meta" in event:
try:
host = event["meta"]["server"]["host"]
@@ -190,7 +190,7 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
await self._send_rename(name)
self.__shared_params.name = name
- elif event_type == "hid_state":
+ elif event_type == "hid":
if (
self._encodings.has_leds_state
and ("keyboard" in event)
diff --git a/kvmd/clients/pst.py b/kvmd/clients/pst.py
index 6b9f5234..868f388c 100644
--- a/kvmd/clients/pst.py
+++ b/kvmd/clients/pst.py
@@ -75,7 +75,7 @@ class PstClient:
if msg.type != aiohttp.WSMsgType.TEXT:
raise PstError(f"Unexpected message type: {msg!r}")
(event_type, event) = htserver.parse_ws_event(msg.data)
- if event_type == "storage_state":
+ if event_type == "storage":
if not event["data"]["write_allowed"]:
raise PstError("Write is not allowed")
path = event["data"]["path"]
diff --git a/web/share/js/kvm/session.js b/web/share/js/kvm/session.js
index 38508f18..fcf20ded 100644
--- a/web/share/js/kvm/session.js
+++ b/web/share/js/kvm/session.js
@@ -368,15 +368,15 @@ export function Session() {
let data = JSON.parse(event.data);
switch (data.event_type) {
case "pong": __missed_heartbeats = 0; break;
- case "info_state": __setInfoState(data.event); break;
- case "gpio_state": __gpio.setState(data.event); break;
- case "hid_state": __hid.setState(data.event); break;
- case "hid_keymaps_state": __paste.setState(data.event); break;
- case "atx_state": __atx.setState(data.event); break;
- case "streamer_state": __streamer.setState(data.event); break;
- case "ocr_state": __ocr.setState(data.event); break;
-
- case "msd_state":
+ case "info": __setInfoState(data.event); break;
+ case "gpio": __gpio.setState(data.event); break;
+ case "hid": __hid.setState(data.event); break;
+ case "hid_keymaps": __paste.setState(data.event); break;
+ case "atx": __atx.setState(data.event); break;
+ case "streamer": __streamer.setState(data.event); break;
+ case "ocr": __ocr.setState(data.event); break;
+
+ case "msd":
if (data.event.online === false) {
__switch.setMsdConnected(false);
} else if (data.event.drive !== undefined) {
@@ -385,7 +385,7 @@ export function Session() {
__msd.setState(data.event);
break;
- case "switch_state":
+ case "switch":
if (data.event.model) {
__atx.setHasSwitch(data.event.model.ports.length > 0);
}