Skip to main content

ThrottledMethodSync

A class in Root.Township, Alta.Networking.

Wraps an entity message so it is sent at most once per set interval; extra sends inside the interval are dropped, not delayed.

Constructors​

MemberWhat it is
ThrottledMethodSync(NetworkEntity entity, EntityMessageType type, SerializeMethod handler, float throttleFrequencyInSeconds)Creates a ThrottledMethodSync from entity, type, handler and throttleFrequencyInSeconds.

Fields​

5 private and internal fields
MemberWhat it is
private readonly NetworkEntity entityThe entity the message belongs to.
private readonly SerializeMethod handlerMethod that writes and reads the message; registered as the entity's handler for type.
private float nextAvailableMessageReal time after which the next send is allowed.
private readonly float throttleFrequencyInSecondsMinimum seconds between sends.
private readonly EntityMessageType typeThe entity message type.

Methods​

MemberWhat it is
void SendToChunks(params Player[] except)Sends the message to players in the entity's chunks (minus except), unless throttled.
void SendToPlayer(Player player)Sends the message to one player, unless throttled.
1 private and internal method
MemberWhat it is
private bool ShouldThrottleMessage()True if the interval has not passed yet; otherwise starts a new interval.

Used in​

Members of other types that take, return or hold a ThrottledMethodSync: