aboutsummaryrefslogtreecommitdiff
path: root/minecraft-protocol/src/connection.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-10 16:27:51 +0000
committermat <github@matdoes.dev>2021-12-10 16:28:12 +0000
commitf9f7e3498e63d6553b67cefc3958c98f009b33a2 (patch)
tree38203a31089fabe1b67b9f6ed6e7e55591929966 /minecraft-protocol/src/connection.rs
parentf6a3f088ac1cd9526e6b93e03ea9929658478565 (diff)
downloadazalea-drasl-f9f7e3498e63d6553b67cefc3958c98f009b33a2.tar.xz
reading packets works
Diffstat (limited to 'minecraft-protocol/src/connection.rs')
-rw-r--r--minecraft-protocol/src/connection.rs15
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(())
}