code beautifying
This commit is contained in:
parent
4f714c1be1
commit
e2b995a788
1 changed files with 3 additions and 16 deletions
19
src/main.rs
19
src/main.rs
|
@ -14,13 +14,6 @@ struct Client {
|
|||
time: DateTime<Local>,
|
||||
}
|
||||
|
||||
fn print_msg(msg: &[u8]) {
|
||||
for elem in msg {
|
||||
print!("{:08b} ", elem);
|
||||
}
|
||||
println!("");
|
||||
}
|
||||
|
||||
fn strip_header(msg: &[u8]) -> Vec<u8> {
|
||||
//print_msg(msg);
|
||||
let mut stripped = Vec::new();
|
||||
|
@ -103,12 +96,6 @@ fn mopp(speed: u8, data: &[u8]) -> Vec<u8> {
|
|||
|
||||
m.replace_range(m.len() - 2.., "11"); // EOW
|
||||
|
||||
println!(
|
||||
"MOPP: {1:0$}",
|
||||
(8 as f32 * (m.len() as f32 / 8 as f32).ceil()) as usize,
|
||||
m
|
||||
);
|
||||
|
||||
m = format!(
|
||||
"{1:0<0$}",
|
||||
(8 as f32 * (m.len() as f32 / 8 as f32).ceil()) as usize,
|
||||
|
@ -156,10 +143,10 @@ fn main() -> std::io::Result<()> {
|
|||
let data = &buf[0..number_of_bytes];
|
||||
|
||||
if receivers.iter().any(|x| x.name == client_addr) {
|
||||
println!("Client already known.");
|
||||
//println!("Client already known.");
|
||||
broadcast(&socket, &receivers, &client, data);
|
||||
} else if strip_header(data) == strip_header(mopp(speed, b"hi").as_slice()) {
|
||||
println!("Welcome!");
|
||||
//println!("Welcome!");
|
||||
if receivers.len() < MAX_CLIENTS {
|
||||
receivers.insert(client.clone());
|
||||
socket
|
||||
|
@ -171,7 +158,7 @@ fn main() -> std::io::Result<()> {
|
|||
.unwrap();
|
||||
}
|
||||
} else {
|
||||
println!("Unknown client - Ignoring");
|
||||
//println!("Unknown client - Ignoring");
|
||||
}
|
||||
|
||||
let timestamp = Local::now();
|
||||
|
|
Loading…
Reference in a new issue