mirror of
https://github.com/OMGeeky/mc-server-rs-sample.git
synced 2025-12-29 07:40:10 +01:00
try to fix some status response stuff
This commit is contained in:
29
src/protocols/ping.rs
Normal file
29
src/protocols/ping.rs
Normal 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(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user