From f9f7e3498e63d6553b67cefc3958c98f009b33a2 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 10 Dec 2021 16:27:51 +0000 Subject: reading packets works --- minecraft-protocol/src/connection.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'minecraft-protocol/src/connection.rs') diff --git a/minecraft-protocol/src/connection.rs b/minecraft-protocol/src/connection.rs index d5cee708..a8319fe1 100644 --- a/minecraft-protocol/src/connection.rs +++ b/minecraft-protocol/src/connection.rs @@ -36,7 +36,7 @@ impl Connection { Ok(Connection { state: ConnectionProtocol::Handshake, - flow: PacketFlow::ClientToServer, + flow: PacketFlow::ServerToClient, stream, }) } @@ -61,12 +61,15 @@ impl Connection { // if we recognize the packet id, parse it - // TODO + let packet = Packet::read( + packet_id.try_into().unwrap(), + &self.state, + &self.flow, + &mut buf, + ) + .await?; - // otherwise, read the rest of the packet and throw it away - let mut packet_data = Vec::with_capacity((packet_size - packet_id_size as i32) as usize); - buf.read_buf(&mut packet_data).await.unwrap(); - println!("packet {:?}", packet_data); + println!("packet: {:?}", packet); Ok(()) } -- cgit v1.2.3