Files
cloudcam/temp/old_protocol.txt

61 lines
1.6 KiB
Plaintext

let mut reconnect = false;
let mut fail_count = 0;
/*
let color = get_color();
let point = Point::at_random_range(-1000.0f32, 1000.0f32, color);
let bytes = point.to_bytes();
//println!("Point : {}", point.debug_string());
if reconnect {
socket = reconnect_socket(&context, socket, SOCKET_ADDRESS);
reconnect = false;
messaging_state = MessagingState::Sending;
}
match messaging_state {
MessagingState::Sending => {
//println!("Sending request...");
//let result = socket.send("hello world!", 0);
let result = socket.send(&bytes, 0);
match result {
Ok(_) => {
//println!("Sent!");
//thread::sleep(Duration::from_millis(250));
messaging_state = MessagingState::Receiving;
},
Err(e) => {
//eprintln!("Send Error ({}): {:?}", e.to_raw(), e);
//thread::sleep(Duration::from_millis(250));
fail_count += 1;
},
}
},
MessagingState::Receiving => {
//println!("Awaiting response...");
let result = socket.recv_bytes(DONTWAIT);
match result {
Ok(_) => {
//println!("Response received!");
messaging_state = MessagingState::Sending;
},
Err(e) => {
//eprintln!("Recv Error ({}): {:?}", e.to_raw(), e);
//thread::sleep(Duration::from_millis(250));
fail_count += 1;
},
}
},
}
if fail_count > 5 {
reconnect = true;
fail_count = 0;
//thread::sleep(Duration::from_millis(2000));
}
*/