From 3204680662282c62276f2be006e96f3384ee7ae0 Mon Sep 17 00:00:00 2001 From: TheLX5 Date: Mon, 6 Jan 2025 16:10:23 -0700 Subject: [PATCH] SNIClient: Let clients based on SNIClient monitor packages via on_package method (#3093) --- SNIClient.py | 3 +++ worlds/AutoSNIClient.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/SNIClient.py b/SNIClient.py index 19440e1d..9140c73c 100644 --- a/SNIClient.py +++ b/SNIClient.py @@ -243,6 +243,9 @@ class SNIContext(CommonContext): # Once the games handled by SNIClient gets made to be remote items, # this will no longer be needed. async_start(self.send_msgs([{"cmd": "LocationScouts", "locations": list(new_locations)}])) + + if self.client_handler is not None: + self.client_handler.on_package(self, cmd, args) def run_gui(self) -> None: from kvui import GameManager diff --git a/worlds/AutoSNIClient.py b/worlds/AutoSNIClient.py index f9444eee..28515d90 100644 --- a/worlds/AutoSNIClient.py +++ b/worlds/AutoSNIClient.py @@ -86,3 +86,7 @@ class SNIClient(abc.ABC, metaclass=AutoSNIClientRegister): async def deathlink_kill_player(self, ctx: SNIContext) -> None: """ override this with implementation to kill player """ pass + + def on_package(self, ctx: SNIContext, cmd: str, args: Dict[str, Any]) -> None: + """ override this with code to handle packages from the server """ + pass