mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-05 11:15:04 +00:00
22 lines
No EOL
624 B
C#
22 lines
No EOL
624 B
C#
using System.Runtime.InteropServices;
|
|
using Shared.Packet.Packets;
|
|
|
|
namespace Shared.Packet;
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct PacketHeader : IPacket {
|
|
// public int Length;
|
|
public Guid Id;
|
|
public PacketType Type;
|
|
|
|
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..]);
|
|
}
|
|
} |