send messages with own speed (20)
This commit is contained in:
parent
6017a6ca47
commit
4f714c1be1
1 changed files with 4 additions and 4 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue