diff options
| author | mat <github@matdoes.dev> | 2021-12-15 13:43:57 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2021-12-15 13:43:57 -0600 |
| commit | 732de94d7b9f1bf2bc9239c8138a37c53242b470 (patch) | |
| tree | eaeaddbf73bf5379fbb1924e57a28b8dad5be48b /minecraft-client/src/ping.rs | |
| parent | ace140500734d33fe53126086a8d9278fa861e21 (diff) | |
| download | azalea-drasl-732de94d7b9f1bf2bc9239c8138a37c53242b470.tar.xz | |
oh yeah it compiles
Diffstat (limited to 'minecraft-client/src/ping.rs')
| -rw-r--r-- | minecraft-client/src/ping.rs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/minecraft-client/src/ping.rs b/minecraft-client/src/ping.rs index 05ea16da..88c0a24a 100644 --- a/minecraft-client/src/ping.rs +++ b/minecraft-client/src/ping.rs @@ -1,13 +1,13 @@ ///! Ping Minecraft servers. use minecraft_protocol::{ - connect::Connection, + connect::HandshakeConnection, packets::{ handshake::client_intention_packet::ClientIntentionPacket, status::{ clientbound_status_response_packet::ClientboundStatusResponsePacket, - serverbound_status_request_packet::ServerboundStatusRequestPacket, + serverbound_status_request_packet::ServerboundStatusRequestPacket, StatusPacket, }, - ConnectionProtocol, Packet, PROTOCOL_VERSION, + ConnectionProtocol, PROTOCOL_VERSION, }, resolver, ServerAddress, }; @@ -17,10 +17,10 @@ pub async fn ping_server( ) -> Result<ClientboundStatusResponsePacket, String> { let resolved_address = resolver::resolve_address(address).await?; - let mut conn = Connection::new(&resolved_address).await?; + let mut conn = HandshakeConnection::new(&resolved_address).await?; // send the client intention packet and switch to the status state - conn.send_packet( + conn.write( ClientIntentionPacket { protocol_version: PROTOCOL_VERSION, hostname: address.host.clone(), @@ -30,16 +30,15 @@ pub async fn ping_server( .get(), ) .await; - conn.switch_state(ConnectionProtocol::Status); + let mut conn = conn.status(); // send the empty status request packet - conn.send_packet(ServerboundStatusRequestPacket {}.get()) - .await; + conn.write(ServerboundStatusRequestPacket {}.get()).await; - let packet = conn.read_packet().await.unwrap(); + let packet = conn.read().await.unwrap(); Ok(match packet { - Packet::ClientboundStatusResponsePacket(p) => p, + StatusPacket::ClientboundStatusResponsePacket(p) => p, _ => Err("Invalid packet type".to_string())?, }) } |
