using System.Buffers.Binary; using GameServer.Network.Packets; using Protocol; namespace GameServer.Network.Messages; internal class RequestMessage : BaseMessage { public override MessageType Type => MessageType.Request; public override int HeaderSize => 13; public ushort RpcID { get; set; } public MessageId MessageId { get; set; } public override void Encode(Memory buffer) { base.Encode(buffer); Span span = buffer.Span; BinaryPrimitives.WriteUInt16LittleEndian(span[5..], RpcID); BinaryPrimitives.WriteUInt16LittleEndian(span[7..], (ushort)MessageId); BinaryPrimitives.WriteUInt32LittleEndian(span[9..], 0); } public override void Decode(ReadOnlyMemory buffer) { base.Decode(buffer); ReadOnlySpan span = buffer.Span; RpcID = BinaryPrimitives.ReadUInt16LittleEndian(span[5..]); MessageId = (MessageId)BinaryPrimitives.ReadUInt16LittleEndian(span[7..]); _ = BinaryPrimitives.ReadUInt32LittleEndian(span[9..]); } }