- [X] Removes network pause/resume - [X] Adds back packet profiler - [X] Adds state machine to keep track and trace netstates - [X] Changes NetState.Running back to using an interlock exchange - [X] Adds preliminary packet throttling support ### Packet Throttling - `[GetThrottle <packetId>` to get the delay in milliseconds for that packet - `[SetThrottle <packetId> <delay>` to set the delay in milliseconds for that packet The settings are saved to `Configuration/throttles.json`
29 lines
765 B
C#
29 lines
765 B
C#
using System;
|
|
|
|
namespace Server.Network
|
|
{
|
|
public delegate void OnPacketReceive(NetState state, CircularBufferReader reader, ref int packetLength);
|
|
|
|
public delegate bool ThrottlePacketCallback(int packetId, NetState state, out bool drop);
|
|
|
|
public class PacketHandler
|
|
{
|
|
public PacketHandler(int packetID, int length, bool ingame, OnPacketReceive onReceive)
|
|
{
|
|
PacketID = packetID;
|
|
Length = length;
|
|
Ingame = ingame;
|
|
OnReceive = onReceive;
|
|
}
|
|
|
|
public int PacketID { get; }
|
|
|
|
public int Length { get; }
|
|
|
|
public OnPacketReceive OnReceive { get; }
|
|
|
|
public ThrottlePacketCallback ThrottleCallback { get; set; }
|
|
|
|
public bool Ingame { get; }
|
|
}
|
|
}
|