add push_back to client

This commit is contained in:
GIKExe 2025-05-05 03:24:15 +03:00
parent bb5dbda37c
commit 21b9e6bb10
2 changed files with 15 additions and 7 deletions

View File

@ -268,6 +268,10 @@ impl ClientContext {
}
}
pub fn push_back(self: &Arc<Self>, packet: Packet){
self.packet_buffer.lock().unwrap().push_back(packet)
}
pub fn close(self: &Arc<Self>) {
self.conn.write().unwrap().close();
}

View File

@ -209,12 +209,14 @@ pub fn send_keep_alive(client: Arc<ClientContext>) -> Result<(), ServerError> {
packet.write_long(timestamp)?;
client.write_packet(&packet)?;
// let mut packet = client.read_packet(serverbound::play::KEEP_ALIVE)?;
// let timestamp2 = packet.read_long()?;
// if timestamp2 != timestamp {
// // Послать клиента нахуй
// println!("KeepAlive Error")
// }
let mut packet = client.read_packet(serverbound::play::KEEP_ALIVE)?;
let timestamp2 = packet.read_long()?;
if timestamp2 != timestamp {
// Послать клиента нахуй
println!("KeepAlive Err")
} else {
println!("KeepAlive Ok")
}
Ok(())
}
@ -280,7 +282,9 @@ pub fn handle_play_state(
client.set_rotation((yaw, pitch));
},
_ => {}
_ => {
client.push_back(packet);
}
}
}