SmoOnlineServer/Shared/Constants.cs

19 lines
671 B
C#
Raw Normal View History

2022-02-04 09:45:38 +00:00
using System.Reflection;
using System.Runtime.InteropServices;
using Shared.Packet;
using Shared.Packet.Packets;
namespace Shared;
public static class Constants {
public const int MaxPacketSize = 256;
public const int MaxClients = 4;
public static int HeaderSize { get; } = Marshal.SizeOf<PacketHeader>();
// dictionary of packet types to packet
public static readonly Dictionary<Type, PacketAttribute> Packets = Assembly
.GetExecutingAssembly()
.GetTypes()
.Where(type => type.IsAssignableTo(typeof(IPacket)))
.ToDictionary(type => type, type => type.GetCustomAttribute<PacketAttribute>()!);
2021-11-29 04:04:34 +00:00
}