fix(core): Tightens the network stack (#479)
- [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`
This commit is contained in:
parent
1736469ac0
commit
8903028b5f
36 changed files with 1018 additions and 405 deletions
|
|
@ -33,22 +33,22 @@ namespace Server.Diagnostics
|
|||
|
||||
public class PacketSendProfile : BasePacketProfile
|
||||
{
|
||||
private static readonly Dictionary<Type, PacketSendProfile> _profiles = new();
|
||||
private static readonly Dictionary<int, PacketSendProfile> _profiles = new();
|
||||
|
||||
private long _created;
|
||||
|
||||
public PacketSendProfile(Type type) : base(type.FullName)
|
||||
public PacketSendProfile(int packetId) : base($"0x{packetId:X2}")
|
||||
{
|
||||
}
|
||||
|
||||
public static IEnumerable<PacketSendProfile> Profiles => _profiles.Values;
|
||||
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
public static PacketSendProfile Acquire(Type type)
|
||||
public static PacketSendProfile Acquire(int packetId)
|
||||
{
|
||||
if (!_profiles.TryGetValue(type, out var prof))
|
||||
if (!_profiles.TryGetValue(packetId, out var prof))
|
||||
{
|
||||
_profiles.Add(type, prof = new PacketSendProfile(type));
|
||||
_profiles.Add(packetId, prof = new PacketSendProfile(packetId));
|
||||
}
|
||||
|
||||
return prof;
|
||||
|
|
@ -72,8 +72,7 @@ namespace Server.Diagnostics
|
|||
private static readonly Dictionary<int, PacketReceiveProfile>
|
||||
_profiles = new();
|
||||
|
||||
public PacketReceiveProfile(int packetId)
|
||||
: base($"0x{packetId:X2}")
|
||||
public PacketReceiveProfile(int packetId) : base($"0x{packetId:X2}")
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue