2022-02-04 09:45:38 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
2022-02-14 19:45:58 +00:00
|
|
|
|
using System.Text;
|
2022-02-04 09:45:38 +00:00
|
|
|
|
|
2022-02-10 01:44:50 +00:00
|
|
|
|
namespace Shared.Packet.Packets;
|
2022-02-04 09:45:38 +00:00
|
|
|
|
|
|
|
|
|
[Packet(PacketType.Connect)]
|
|
|
|
|
public struct ConnectPacket : IPacket {
|
|
|
|
|
public ConnectionTypes ConnectionType;
|
2022-02-14 22:09:55 +00:00
|
|
|
|
public string ClientName = "?????";
|
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 ConnectionType);
|
2022-02-14 19:45:58 +00:00
|
|
|
|
Encoding.UTF8.GetBytes(ClientName).CopyTo(data[4..(4 + Constants.CostumeNameSize)]);
|
2022-02-04 09:45:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Deserialize(Span<byte> data) {
|
|
|
|
|
ConnectionType = MemoryMarshal.Read<ConnectionTypes>(data);
|
2022-02-14 19:45:58 +00:00
|
|
|
|
ClientName = Encoding.UTF8.GetString(data[4..(4 + Constants.CostumeNameSize)]).TrimNullTerm();
|
2022-02-04 09:45:38 +00:00
|
|
|
|
}
|
2021-11-29 04:04:34 +00:00
|
|
|
|
}
|