try to fix some status response stuff

This commit is contained in:
OMGeeky
2024-11-14 18:04:53 +01:00
parent c6d703f167
commit df1908bfaa
9 changed files with 193 additions and 63 deletions

29
src/protocols/ping.rs Normal file
View File

@@ -0,0 +1,29 @@
use crate::types::var_int::VarInt;
use crate::types::var_long::VarLong;
use crate::types::{McRead, McWrite};
use crate::utils::RWStreamWithLimit;
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
pub struct Protocol {}
impl Protocol {
pub async fn handle<T: AsyncRead + AsyncWrite + Unpin>(
stream: &mut RWStreamWithLimit<'_, T>,
) -> Result<(), bool> {
println!("Ping");
let v = stream.read_i64().await.map_err(|e| {
dbg!(e);
false
})?;
VarInt(0x01).write_stream(stream).await.map_err(|x| {
dbg!(x);
false
})?;
stream.write_i64(v).await.map_err(|e| {
dbg!(e);
false
})?;
Ok(())
}
}