Remove main.rs
This commit is contained in:
parent
ff9b2d3f96
commit
145181e364
1 changed files with 0 additions and 54 deletions
54
src/main.rs
54
src/main.rs
|
@ -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(())
|
||||
}
|
Loading…
Reference in a new issue