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>) { pub fn close(self: &Arc<Self>) {
self.conn.write().unwrap().close(); 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)?; packet.write_long(timestamp)?;
client.write_packet(&packet)?; client.write_packet(&packet)?;
// let mut packet = client.read_packet(serverbound::play::KEEP_ALIVE)?; let mut packet = client.read_packet(serverbound::play::KEEP_ALIVE)?;
// let timestamp2 = packet.read_long()?; let timestamp2 = packet.read_long()?;
// if timestamp2 != timestamp { if timestamp2 != timestamp {
// // Послать клиента нахуй // Послать клиента нахуй
// println!("KeepAlive Error") println!("KeepAlive Err")
// } } else {
println!("KeepAlive Ok")
}
Ok(()) Ok(())
} }
@ -280,7 +282,9 @@ pub fn handle_play_state(
client.set_rotation((yaw, pitch)); client.set_rotation((yaw, pitch));
}, },
_ => {} _ => {
client.push_back(packet);
}
} }
} }