Remove main.rs

This commit is contained in:
Leon Grünewald 2024-09-17 00:28:48 +02:00
parent ff9b2d3f96
commit 145181e364

View file

@ -1,54 +0,0 @@
use std::net::ToSocketAddrs;
use std::time::{Duration, SystemTime};
use futures::{SinkExt, StreamExt};
use mumble_rs::{MumbleClient, MumbleMessage};
use mumble_rs::proto::Ping;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let mut client = MumbleClient::new("127.0.0.1:64738".to_socket_addrs()?.next().unwrap());
let (mut mumble_send, mut mumble_recv) = client.connect().await?.split();
let mut server_synced = false;
let (mut conn_send_channel_send, mut conn_send_channel_recv) = tokio::sync::mpsc::channel::<MumbleMessage>(10);
tokio::spawn(async move {
while !conn_send_channel_send.is_closed() {
conn_send_channel_send.send(MumbleMessage::Ping {data: Ping {
good: None,
late: None,
lost: None,
resync: None,
tcp_packets: None,
tcp_ping_avg: None,
tcp_ping_var: None,
timestamp: Some(SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs()),
udp_packets: None,
udp_ping_avg: None,
udp_ping_var: None
}}).await.unwrap();
tokio::time::sleep(Duration::from_secs(10)).await;
}
});
tokio::spawn(async move {
while let Some(message) = conn_send_channel_recv.recv().await {
mumble_send.send(message).await.unwrap();
}
});
while let Some(frame_result) = mumble_recv.next().await {
if let Ok(message) = frame_result {
match message {
MumbleMessage::UserState {data} => {
if !server_synced { continue }
println!("{data:?}")
}
MumbleMessage::ServerSync {data} => {
server_synced = true;
}
_ => {}
}
}
}
Ok(())
}