Fix VNC connection
This commit is contained in:
@ -84,11 +84,27 @@ impl VNCActor {
|
||||
let mut buff: [u8; 5000] = [0; 5000];
|
||||
loop {
|
||||
match read_half.read(&mut buff).await {
|
||||
Ok(l) => {
|
||||
Ok(mut l) => {
|
||||
if l == 0 {
|
||||
log::error!("Got empty read. Closing read end...");
|
||||
addr.do_send(CloseWebSocketReq);
|
||||
return;
|
||||
log::warn!("Got empty read!");
|
||||
|
||||
// Ugly hack made to wait for next byte
|
||||
let mut one_byte_buff: [u8; 1] = [0; 1];
|
||||
match read_half.read_exact(&mut one_byte_buff).await {
|
||||
Ok(b) => {
|
||||
if b == 0 {
|
||||
log::error!("Did not get a byte !");
|
||||
let _ = addr.send(CloseWebSocketReq).await;
|
||||
break;
|
||||
}
|
||||
buff[0] = one_byte_buff[0];
|
||||
l = 1;
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to read 1 BYTE from remote socket. Stopping now... {:?}", e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let to_send = SendBytesReq(Vec::from(&buff[0..l]));
|
||||
|
Reference in New Issue
Block a user