diff options
| author | Party Wumpus <48649272+PartyWumpus@users.noreply.github.com> | 2024-02-15 22:28:36 +0000 |
|---|---|---|
| committer | Party Wumpus <48649272+PartyWumpus@users.noreply.github.com> | 2024-02-15 22:28:36 +0000 |
| commit | 867ce63f7bc67cb418d96d226a7e3eaf2b05bc87 (patch) | |
| tree | 5424e3374c2f66e25d6fa0a80bc4f6f3e18fa84d /backend/decky_loader/wsrouter.py | |
| parent | ee6122b97d042e8bb50531511d6c0103e0d6a358 (diff) | |
| download | decky-loader-867ce63f7bc67cb418d96d226a7e3eaf2b05bc87.tar.gz decky-loader-867ce63f7bc67cb418d96d226a7e3eaf2b05bc87.zip | |
Add event handler
Diffstat (limited to 'backend/decky_loader/wsrouter.py')
| -rw-r--r-- | backend/decky_loader/wsrouter.py | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/backend/decky_loader/wsrouter.py b/backend/decky_loader/wsrouter.py index 8b145dc3..4874e967 100644 --- a/backend/decky_loader/wsrouter.py +++ b/backend/decky_loader/wsrouter.py @@ -7,9 +7,7 @@ from aiohttp.web import Application, WebSocketResponse, Request, Response, get from enum import IntEnum -from typing import Callable, Coroutine, Dict, Any, cast, TypeVar, Type - -from dataclasses import asdict, is_dataclass +from typing import Callable, Coroutine, Dict, Any, cast, TypeVar from traceback import format_exc @@ -127,11 +125,6 @@ class WSRouter: self.logger.debug('Websocket connection closed') return ws - # DataType defaults to None so that if a plugin opts in to strict pyright checking and attempts to pass data witbout specifying the type (or any), the type check fails - async def emit(self, event: str, data: DataType | None = None, data_type: Type[DataType] | None = None): - self.logger.debug('Firing frontend event %s with args %s', data) - sent_data: Dict[Any, Any] | None = cast(Dict[Any, Any], data) - if is_dataclass(data): - sent_data = asdict(data) # type: ignore Argument of type "DataclassInstance | type[DataclassInstance]" cannot be assigned to parameter "obj" of type "DataclassInstance" in function "asdict" - - await self.write({ "type": MessageType.EVENT.value, "event": event, "data": sent_data }) + async def emit(self, event: str, *args: Any): + self.logger.debug(f'Firing frontend event {event} with args {args}') + await self.write({ "type": MessageType.EVENT.value, "event": event, "args": args }) |
