diff options
| author | mat <github@matdoes.dev> | 2021-12-17 16:38:14 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2021-12-17 16:38:14 -0600 |
| commit | 493aae582adbf818dc4cfdbd0390961d36647d77 (patch) | |
| tree | 9ff582af7c4781a78b1a43c603ae771451325e94 /azalea-client/src | |
| parent | c4eecaf13a4f8f0a81dc278078727df23caa8411 (diff) | |
| download | azalea-drasl-493aae582adbf818dc4cfdbd0390961d36647d77.tar.xz | |
fix packets
Diffstat (limited to 'azalea-client/src')
| -rw-r--r-- | azalea-client/src/connect.rs | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index 2a2eb1ac..07c2e0d0 100644 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -33,19 +33,25 @@ pub async fn join_server(address: &ServerAddress) -> Result<(), String> { conn.write(ServerboundHelloPacket { username }.get()).await; let mut conn = loop { - match conn.read().await.unwrap() { - LoginPacket::ClientboundHelloPacket(p) => { - println!("Got encryption request {:?} {:?}", p.nonce, p.public_key); + let packet_result = conn.read().await; + match packet_result { + Ok(packet) => match packet { + LoginPacket::ClientboundHelloPacket(p) => { + println!("Got encryption request {:?} {:?}", p.nonce, p.public_key); + } + LoginPacket::ClientboundLoginCompressionPacket(p) => { + println!("Got compression request {:?}", p.compression_threshold); + conn.set_compression_threshold(p.compression_threshold); + } + LoginPacket::ClientboundGameProfilePacket(p) => { + println!("Got profile {:?}", p.game_profile); + break conn.game(); + } + _ => panic!("unhandled packet"), + }, + Err(e) => { + println!("Error: {:?}", e); } - LoginPacket::ClientboundLoginCompressionPacket(p) => { - println!("Got compression request {:?}", p.compression_threshold); - conn.set_compression_threshold(p.compression_threshold); - } - LoginPacket::ClientboundGameProfilePacket(p) => { - println!("Got profile {:?}", p.game_profile); - break conn.game(); - } - _ => panic!("unhandled packet"), } }; |
