mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-15 08:05:06 +00:00
534a6c9655
speedrun flag
26 lines
No EOL
766 B
C#
26 lines
No EOL
766 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 short PacketSize;
|
|
|
|
public short Size => 20;
|
|
|
|
public void Serialize(Span<byte> data) {
|
|
MemoryMarshal.Write(data, ref Id);
|
|
MemoryMarshal.Write(data[16..], ref Type);
|
|
MemoryMarshal.Write(data[18..], ref PacketSize);
|
|
}
|
|
|
|
public void Deserialize(ReadOnlySpan<byte> data) {
|
|
Id = MemoryMarshal.Read<Guid>(data);
|
|
Type = MemoryMarshal.Read<PacketType>(data[16..]);
|
|
PacketSize = MemoryMarshal.Read<short>(data[16..]);
|
|
}
|
|
} |