0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-25 12:45:18 +00:00
SmoOnlineServer/Shared/Packet/PacketHeader.cs

22 lines
624 B
C#
Raw Normal View History

2022-02-04 09:45:38 +00:00
using System.Runtime.InteropServices;
using Shared.Packet.Packets;
2022-02-10 01:44:50 +00:00
namespace Shared.Packet;
2022-02-04 09:45:38 +00:00
[StructLayout(LayoutKind.Sequential)]
public struct PacketHeader : IPacket {
// public int Length;
public Guid Id;
public PacketType Type;
2022-02-10 01:44:50 +00:00
2022-02-04 09:45:38 +00:00
public void Serialize(Span<byte> data) {
// MemoryMarshal.Write(data, ref Length);
MemoryMarshal.Write(data, ref Id);
MemoryMarshal.Write(data[16..], ref Type);
}
public void Deserialize(Span<byte> data) {
Id = MemoryMarshal.Read<Guid>(data);
Type = MemoryMarshal.Read<PacketType>(data[16..]);
}
2021-11-29 04:04:34 +00:00
}