code cleanup
This commit is contained in:
parent
7d60561f63
commit
6fa55cdc61
1 changed files with 14 additions and 14 deletions
|
@ -95,6 +95,7 @@ fn mopp(speed: u8, data: &[u8]) -> Vec<u8> {
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut res = Vec::<u8>::new();
|
let mut res = Vec::<u8>::new();
|
||||||
|
|
||||||
for i in (0..m.len()).step_by(8) {
|
for i in (0..m.len()).step_by(8) {
|
||||||
let value = u8::from_str_radix(&m[i..i + 8], 2).unwrap();
|
let value = u8::from_str_radix(&m[i..i + 8], 2).unwrap();
|
||||||
res.push(value);
|
res.push(value);
|
||||||
|
@ -118,8 +119,7 @@ fn broadcast(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_old_clients(socket: &UdpSocket,
|
fn remove_old_clients(socket: &UdpSocket, subscribers: &mut HashMap<String, DateTime<Local>>) {
|
||||||
subscribers: &mut HashMap<String, DateTime<Local>>,) {
|
|
||||||
let timestamp = Local::now();
|
let timestamp = Local::now();
|
||||||
|
|
||||||
debug!("Number of clients: {}", subscribers.len());
|
debug!("Number of clients: {}", subscribers.len());
|
||||||
|
@ -134,7 +134,7 @@ fn remove_old_clients(socket: &UdpSocket,
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribers.retain(|_, val| *val + Duration::seconds(CLIENT_TIMEOUT as i64) >= timestamp);
|
subscribers.retain(|_, val| *val + Duration::seconds(CLIENT_TIMEOUT as i64) >= timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> std::io::Result<()> {
|
fn main() -> std::io::Result<()> {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
Loading…
Reference in a new issue