aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/command.rs
diff options
context:
space:
mode:
authorEskil Queseth <eskilq@kth.se>2021-05-19 02:09:58 +0200
committerEskil Queseth <eskilq@kth.se>2021-05-19 02:09:58 +0200
commitf551de2bbc5e41c5cd76e36c2b0a6f10d9b4cddf (patch)
tree750cbad28427067b66fa690236a25ea3374bd9aa /mumd/src/command.rs
parentcf81a1141cdc6a6db842d992d065eba74829e0c7 (diff)
downloadmum-f551de2bbc5e41c5cd76e36c2b0a6f10d9b4cddf.tar.gz
remove event_register_handler from tcp stack
Diffstat (limited to 'mumd/src/command.rs')
-rw-r--r--mumd/src/command.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/mumd/src/command.rs b/mumd/src/command.rs
index 1337dce..a62ddbd 100644
--- a/mumd/src/command.rs
+++ b/mumd/src/command.rs
@@ -1,8 +1,4 @@
-use crate::network::{
- ConnectionInfo,
- tcp::{TcpEvent, TcpEventCallback},
- udp::PingRequest
-};
+use crate::network::{ConnectionInfo, tcp::TcpEventQueue, udp::PingRequest};
use crate::state::{ExecutionContext, State};
use log::*;
@@ -17,7 +13,7 @@ pub async fn handle(
Command,
oneshot::Sender<mumlib::error::Result<Option<CommandResponse>>>,
)>,
- tcp_event_register_sender: mpsc::UnboundedSender<(TcpEvent, TcpEventCallback)>,
+ tcp_event_queue: TcpEventQueue,
ping_request_sender: mpsc::UnboundedSender<PingRequest>,
mut packet_sender: mpsc::UnboundedSender<ControlPacket<Serverbound>>,
mut connection_info_sender: watch::Sender<Option<ConnectionInfo>>,
@@ -33,14 +29,14 @@ pub async fn handle(
ExecutionContext::TcpEvent(event, generator) => {
let (tx, rx) = oneshot::channel();
//TODO handle this error
- let _ = tcp_event_register_sender.send((
- event,
+ tcp_event_queue.register_callback(
+ event,
Box::new(move |e| {
let response = generator(e);
response_sender.send(response).unwrap();
tx.send(()).unwrap();
}),
- ));
+ );
rx.await.unwrap();
}