This commit is contained in:
2025-07-19 03:45:57 +02:00
parent 51118fee63
commit 0e9c2b08d6
10 changed files with 1487 additions and 462 deletions

View File

@@ -1,4 +1,3 @@
use tokio::sync::mpsc;
use crate::network::protocol::{UDPMessage};
#[derive(Clone, Debug)]
@@ -16,12 +15,12 @@ pub enum Event {
#[derive(Clone)]
pub struct EventBus {
pub sender: mpsc::Sender<Event>,
pub sender: kanal::AsyncSender<Event>,
}
impl EventBus {
pub fn new() -> (Self, mpsc::Receiver<Event>) {
let (sender, receiver) = mpsc::channel(10000);
pub fn new() -> (Self, kanal::AsyncReceiver<Event>) {
let (sender, receiver) = kanal::bounded_async::<Event>(4096);
(Self { sender }, receiver)
}
@@ -33,7 +32,7 @@ impl EventBus {
let _ = self.sender.try_send(event);
}
pub fn clone_sender(&self) -> mpsc::Sender<Event> {
pub fn clone_sender(&self) -> kanal::AsyncSender<Event> {
self.sender.clone()
}
}