From 72a5aac40da73e8ab757cae754a2a46ef3b6918a Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 13 Apr 2026 18:28:08 -0500 Subject: [PATCH] feat(identity_context): implement receive completed handler for RNCP and enhance teardown process for receive destination --- meshchatx/src/backend/identity_context.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/meshchatx/src/backend/identity_context.py b/meshchatx/src/backend/identity_context.py index 4a78bc4..c4dccfa 100644 --- a/meshchatx/src/backend/identity_context.py +++ b/meshchatx/src/backend/identity_context.py @@ -93,6 +93,18 @@ class IdentityContext: self.running = False + def _rncp_emit_receive_completed(self, payload): + try: + from meshchatx.src.backend.async_utils import AsyncUtils + + AsyncUtils.run_async( + self.app._broadcast_websocket_message( + {"type": "rncp.receive.completed", **payload}, + ), + ) + except Exception: + pass + def setup(self): print(f"Setting up Identity Context for {self.identity_hash}...") @@ -235,6 +247,7 @@ class IdentityContext: identity=self.identity, storage_dir=self.app.storage_dir, ) + self.rncp_handler.on_receive_completed = self._rncp_emit_receive_completed self.rnstatus_handler = RNStatusHandler( reticulum_instance=getattr(self.app, "reticulum", None), ) @@ -479,6 +492,11 @@ class IdentityContext: # 2. Cleanup RNS destinations and links try: + if self.rncp_handler: + with contextlib.suppress(Exception): + self.rncp_handler.teardown_receive_destination() + self.rncp_handler = None + if self.message_router: # Break cycles in mocks/objects if hasattr(self.message_router, "register_delivery_callback"):