From c37cedf183a8359340c263711a2801fcfedfcad7 Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Sun, 26 Feb 2023 00:31:36 +0700 Subject: [PATCH] Added the unhandler --- crates/core/src/bc_protocol/connection/bcconn.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/core/src/bc_protocol/connection/bcconn.rs b/crates/core/src/bc_protocol/connection/bcconn.rs index b59862a..5a14030 100644 --- a/crates/core/src/bc_protocol/connection/bcconn.rs +++ b/crates/core/src/bc_protocol/connection/bcconn.rs @@ -112,6 +112,13 @@ impl BcConnection { Ok(()) } + /// Stop a message handler created using [`handle_msg`] + #[allow(dead_code)] // Currently unused but added for future use + pub async fn unhandle_msg(&self, msg_id: u32) -> Result<()> { + self.subscribers.id.write().await.remove(&msg_id); + Ok(()) + } + async fn poll(response: Bc, subscribers: &Subscriber, sink: &Mutex) -> Result<()> { // Don't hold the lock during deserialization so we don't poison the subscribers mutex if // something goes wrong