From 7fb14d648aacd398f720f60236020dab6bf9fd35 Mon Sep 17 00:00:00 2001 From: Eskil Queseth Date: Wed, 14 Oct 2020 16:54:27 +0200 Subject: add support for disconnect command --- mumd/src/main.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'mumd/src/main.rs') diff --git a/mumd/src/main.rs b/mumd/src/main.rs index a2665ba..c923857 100644 --- a/mumd/src/main.rs +++ b/mumd/src/main.rs @@ -11,14 +11,18 @@ use argparse::ArgumentParser; use argparse::Store; use argparse::StoreTrue; use colored::*; -use futures::channel::oneshot; -use futures::join; +use tokio::sync::oneshot; +use futures::{join, select}; use log::*; use mumble_protocol::control::ControlPacket; use mumble_protocol::crypt::ClientCryptState; use mumble_protocol::voice::Serverbound; use std::sync::{Arc, Mutex}; use tokio::sync::{mpsc, watch}; +use std::thread; +use std::time::Duration; +use tokio::stream::StreamExt; +use futures::FutureExt; #[tokio::main] async fn main() { @@ -79,7 +83,7 @@ async fn main() { command_sender.send(Command::ChannelList).unwrap(); command_sender.send(Command::ServerConnect{host: server_host, port: server_port, username: username.clone(), accept_invalid_cert}); - command_sender.send(Command::ChannelJoin{channel_id: 1}).unwrap(); + //command_sender.send(Command::ChannelJoin{channel_id: 1}).unwrap(); command_sender.send(Command::ChannelList).unwrap(); let state = State::new(packet_sender, command_sender.clone(), connection_info_sender, username); let state = Arc::new(Mutex::new(state)); @@ -102,16 +106,28 @@ async fn main() { command_receiver, command_response_sender, ), + send_commands( + command_sender + ), receive_command_responses( command_response_receiver, ), ); } +async fn send_commands(command_sender: mpsc::UnboundedSender) { + tokio::time::delay_for(Duration::from_secs(5)).await; + command_sender.send(Command::ServerDisconnect); + + debug!("Finished sending commands"); +} + async fn receive_command_responses( mut command_response_receiver: mpsc::UnboundedReceiver, ()>>, ) { while let Some(command_response) = command_response_receiver.recv().await { - debug!("{:#?}", command_response); + debug!("{:?}", command_response); } + + debug!("Finished receiving commands"); } -- cgit v1.2.1