aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/command.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mumd/src/command.rs')
-rw-r--r--mumd/src/command.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/mumd/src/command.rs b/mumd/src/command.rs
index 330e3fc..e77b34b 100644
--- a/mumd/src/command.rs
+++ b/mumd/src/command.rs
@@ -1,13 +1,16 @@
+use crate::network::{
+ ConnectionInfo,
+ tcp::{TcpEvent, TcpEventCallback},
+ udp::PingRequest
+};
use crate::state::{ExecutionContext, State};
-use crate::network::tcp::{TcpEvent, TcpEventCallback};
use ipc_channel::ipc::IpcSender;
use log::*;
-use mumble_protocol::ping::PongPacket;
+use mumble_protocol::{Serverbound, control::ControlPacket};
use mumlib::command::{Command, CommandResponse};
-use std::net::SocketAddr;
use std::sync::{Arc, Mutex};
-use tokio::sync::{mpsc, oneshot};
+use tokio::sync::{mpsc, oneshot, watch};
pub async fn handle(
state: Arc<Mutex<State>>,
@@ -16,13 +19,15 @@ pub async fn handle(
IpcSender<mumlib::error::Result<Option<CommandResponse>>>,
)>,
tcp_event_register_sender: mpsc::UnboundedSender<(TcpEvent, TcpEventCallback)>,
- ping_request_sender: mpsc::UnboundedSender<(u64, SocketAddr, Box<dyn FnOnce(PongPacket)>)>,
+ ping_request_sender: mpsc::UnboundedSender<PingRequest>,
+ mut packet_sender: mpsc::UnboundedSender<ControlPacket<Serverbound>>,
+ mut connection_info_sender: watch::Sender<Option<ConnectionInfo>>,
) {
debug!("Begin listening for commands");
while let Some((command, response_sender)) = command_receiver.recv().await {
debug!("Received command {:?}", command);
let mut state = state.lock().unwrap();
- let event = state.handle_command(command);
+ let event = state.handle_command(command, &mut packet_sender, &mut connection_info_sender);
drop(state);
match event {
ExecutionContext::TcpEvent(event, generator) => {