From 4f714c1be1be3ca75a05e255a1c1e69d041b1389 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Tue, 3 Oct 2023 19:56:13 +0200 Subject: [PATCH] send messages with own speed (20) --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 74e3942..2e4ca0b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ use std::{ const MAX_CLIENTS: usize = 10; const CLIENT_TIMEOUT: u32 = 300; +const MY_SPEED: u8 = 20; #[derive(Hash, Eq, PartialEq, Debug, Clone)] struct Client { @@ -151,7 +152,6 @@ fn main() -> std::io::Result<()> { time: Local::now(), }; let speed = buf[1] >> 2; - println!("Speed: {speed} WPM"); let data = &buf[0..number_of_bytes]; @@ -163,11 +163,11 @@ fn main() -> std::io::Result<()> { if receivers.len() < MAX_CLIENTS { receivers.insert(client.clone()); socket - .send_to(mopp(speed, b"hi").as_slice(), &client.name) + .send_to(mopp(MY_SPEED, b"hi").as_slice(), &client.name) .unwrap(); } else { socket - .send_to(mopp(speed, b":qrl").as_slice(), &client.name) + .send_to(mopp(MY_SPEED, b":qrl").as_slice(), &client.name) .unwrap(); } } else { @@ -178,7 +178,7 @@ fn main() -> std::io::Result<()> { for cl in &receivers { if cl.time + Duration::seconds(CLIENT_TIMEOUT as i64) < timestamp { socket - .send_to(mopp(speed, b":bye").as_slice(), &client.name) + .send_to(mopp(MY_SPEED, b":bye").as_slice(), &client.name) .unwrap(); } }