Added ProtocolConnection::forward_play function

This commit is contained in:
Kyler 2024-05-31 17:24:34 -06:00
parent 271dadae0f
commit 505adfb92c
1 changed files with 13 additions and 0 deletions

View File

@ -13,6 +13,7 @@ use rand::Rng;
use crate::login; use crate::login;
use crate::encrypt; use crate::encrypt;
use crate::play::Play;
pub type Result<T> = std::result::Result<T, Box<dyn Error>>; pub type Result<T> = std::result::Result<T, Box<dyn Error>>;
@ -235,6 +236,18 @@ impl<'a> ProtocolConnection<'a> {
None => Err(Box::new(PacketError::EncryptionError)) None => Err(Box::new(PacketError::EncryptionError))
} }
} }
pub async fn forward_play(
&mut self,
other: &mut ProtocolConnection<'_>,
) -> Result<()> {
loop {
let packet = Play::read(self).await?;
match packet {
Play::PlayPacket(packet) => packet.write(other).await?,
};
}
}
} }
#[async_trait] #[async_trait]