Drain RUDP content traffic without per-packet sleeps

This commit is contained in:
Meta Vens 2026-07-16 02:36:07 +01:00
commit 25231429c1
5 changed files with 136 additions and 28 deletions

View file

@ -247,15 +247,16 @@ namespace GameCult.Networking
return;
}
var message = transport.ReceiveSchemaMessageOnce();
transport.PollResends();
if (message != null)
var consumed = 0;
while (consumed < 256 && transport.TryReceiveOnce(out var frame))
{
Dispatch(message);
consumed++;
if (frame != null && string.Equals(frame.ChannelId, "schema", StringComparison.Ordinal))
Dispatch(CultNetSchemaMessageSerialization.Deserialize(frame.Payload));
}
Thread.Sleep(1);
transport.PollResends();
if (consumed == 0)
Thread.Sleep(1);
}
}
catch (ObjectDisposedException) when (_disposed)