From c4eecaf13a4f8f0a81dc278078727df23caa8411 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 16 Dec 2021 23:33:06 -0600 Subject: try to implement compression --- azalea-client/src/connect.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'azalea-client/src') diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs index fad5fa92..2a2eb1ac 100644 --- a/azalea-client/src/connect.rs +++ b/azalea-client/src/connect.rs @@ -29,25 +29,28 @@ pub async fn join_server(address: &ServerAddress) -> Result<(), String> { .await; let mut conn = conn.login(); - // login start + // login conn.write(ServerboundHelloPacket { username }.get()).await; - // encryption request - loop { + let mut conn = loop { match conn.read().await.unwrap() { - LoginPacket::ClientboundHelloPacket(encryption_request_packet) => { - println!( - "Got encryption request {:?} {:?}", - encryption_request_packet.nonce, encryption_request_packet.public_key - ); + 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"), } - } - - // TODO: client auth + }; - // TODO: encryption response + // game + panic!("ok i haven't implemented game yet"); Ok(()) } -- cgit v1.2.3