From 31cb6ff49dc134cd44ae26f63b74712f551c3d13 Mon Sep 17 00:00:00 2001 From: ImSoZRious Date: Fri, 7 Jul 2023 14:48:26 +0700 Subject: [PATCH] fix: did not send data --- src/replayer.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/replayer.rs b/src/replayer.rs index 962d616..5d93fcc 100644 --- a/src/replayer.rs +++ b/src/replayer.rs @@ -41,7 +41,18 @@ impl Replayer { rx } - pub async fn add_data(&self, data: T) { - self.data.write().await.push(data); + pub async fn add_data(&self, data: T) + where + T: Send + Sync + Clone + 'static + { + self.data.write().await.push(data.clone()); + + let all_tx = self.txs.read().await.clone(); + + for mut tx in all_tx.into_iter() { + if let Err(e) = tx.send(data.clone()).await { + tracing::warn!("Unable to send data: {e}"); + } + } } }