diff options
| author | mat <github@matdoes.dev> | 2021-12-10 16:27:51 +0000 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2021-12-10 16:28:12 +0000 |
| commit | f9f7e3498e63d6553b67cefc3958c98f009b33a2 (patch) | |
| tree | 38203a31089fabe1b67b9f6ed6e7e55591929966 /minecraft-protocol/src/connection.rs | |
| parent | f6a3f088ac1cd9526e6b93e03ea9929658478565 (diff) | |
| download | azalea-drasl-f9f7e3498e63d6553b67cefc3958c98f009b33a2.tar.xz | |
reading packets works
Diffstat (limited to 'minecraft-protocol/src/connection.rs')
| -rw-r--r-- | minecraft-protocol/src/connection.rs | 15 |
1 files changed, 9 insertions, 6 deletions
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(()) } |
