1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-06-30 03:37:45 +00:00

Don't make packet parsing async

This doesn't need to be marked as async, the code isn't.
This commit is contained in:
Joshua Goins 2025-06-26 19:09:13 -04:00
parent c5695f5ed7
commit 4f364ae330
5 changed files with 8 additions and 8 deletions

View file

@ -60,7 +60,7 @@ async fn main() {
.expect("Failed to read data!");
if n != 0 {
let (segments, _) = connection.parse_packet(&buf[..n]).await;
let (segments, _) = connection.parse_packet(&buf[..n]);
for segment in &segments {
match &segment.data {
SegmentData::SecuritySetup { phrase, key } => {

View file

@ -147,7 +147,7 @@ async fn client_loop(
if n > 0 {
connection.last_keep_alive = Instant::now();
let (segments, connection_type) = connection.parse_packet(&buf[..n]).await;
let (segments, connection_type) = connection.parse_packet(&buf[..n]);
for segment in &segments {
match &segment.data {
SegmentData::None() => {},

View file

@ -40,11 +40,11 @@ pub struct LobbyConnection {
}
impl LobbyConnection {
pub async fn parse_packet(
pub fn parse_packet(
&mut self,
data: &[u8],
) -> (Vec<PacketSegment<ClientLobbyIpcSegment>>, ConnectionType) {
parse_packet(data, &mut self.state).await
parse_packet(data, &mut self.state)
}
pub async fn send_segment(&mut self, segment: PacketSegment<ServerLobbyIpcSegment>) {
@ -567,7 +567,7 @@ pub async fn send_custom_world_packet(segment: CustomIpcSegment) -> Option<Custo
let mut buf = vec![0; RECEIVE_BUFFER_SIZE];
let n = stream.read(&mut buf).await.expect("Failed to read data!");
if n != 0 {
let (segments, _) = parse_packet::<CustomIpcSegment>(&buf[..n], &mut packet_state).await;
let (segments, _) = parse_packet::<CustomIpcSegment>(&buf[..n], &mut packet_state);
return match &segments[0].data {
SegmentData::KawariIpc { data } => Some(data.clone()),

View file

@ -222,7 +222,7 @@ pub struct PacketState {
pub clientbound_oodle: OodleNetwork,
}
pub async fn parse_packet<T: ReadWriteIpcSegment>(
pub fn parse_packet<T: ReadWriteIpcSegment>(
data: &[u8],
state: &mut PacketState,
) -> (Vec<PacketSegment<T>>, ConnectionType) {

View file

@ -130,11 +130,11 @@ pub struct ZoneConnection {
}
impl ZoneConnection {
pub async fn parse_packet(
pub fn parse_packet(
&mut self,
data: &[u8],
) -> (Vec<PacketSegment<ClientZoneIpcSegment>>, ConnectionType) {
parse_packet(data, &mut self.state).await
parse_packet(data, &mut self.state)
}
pub async fn send_segment(&mut self, segment: PacketSegment<ServerZoneIpcSegment>) {