a bit of condensing
This commit is contained in:
parent
1f132c8863
commit
6c8f5c44f7
1 changed files with 4 additions and 9 deletions
13
src/main.rs
13
src/main.rs
|
@ -40,17 +40,12 @@ fn main() {
|
||||||
match from_socket_rx.recv_timeout(Duration::from_millis(100)) {
|
match from_socket_rx.recv_timeout(Duration::from_millis(100)) {
|
||||||
Ok(message) => {
|
Ok(message) => {
|
||||||
println!("main recieved: {}", message);
|
println!("main recieved: {}", message);
|
||||||
let json = serde_json::from_str(&message).unwrap();
|
let update = StateUpdate::json_to_state_update(
|
||||||
let update = StateUpdate::json_to_state_update(json);
|
serde_json::from_str(&message).unwrap());
|
||||||
if update == StateUpdate::UpdateClient {
|
if update == StateUpdate::UpdateClient {
|
||||||
update_all(&state, &socket);
|
update_all(&state, &socket);
|
||||||
}
|
} else {
|
||||||
let updates = state.handle_update(update, &hotkeys);
|
handle_instructions(vec![update], &mut state, &socket, &hotkeys);
|
||||||
if updates.0.is_some() {
|
|
||||||
socket.send(updates.0.unwrap().to_json().to_string());
|
|
||||||
}
|
|
||||||
if updates.1.is_some() {
|
|
||||||
handle_instructions(updates.1.unwrap(), &mut state, &socket, &hotkeys);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {},
|
Err(_) => {},
|
||||||
|
|
Loading…
Reference in a new issue