ace/Source/ACE.Server/Network/PacketFragmentHeader.cs
fartwhif 9e065e89df WAN reliability, message queues, refactoring (#822)
* attempt to "group" network transmissions

* WAN sessions are now at least reliable enough to test with
refactor PacketFragmentHeader.Queue to match aclogview
refactor Packet.Header.Iteration to match aclogview
included some missing header flags from aclogview
include aclogview packet header flag names as comments
refactor typo in packet header flag names
2018-06-15 12:56:22 -04:00

46 lines
1.3 KiB
C#

using System.IO;
using System.Runtime.InteropServices;
namespace ACE.Server.Network
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public class PacketFragmentHeader
{
public static uint HeaderSize { get; } = 16u;
public uint Sequence { get; set; }
public uint Id { get; set; }
public ushort Count { get; set; }
public ushort Size { get; set; }
public ushort Index { get; set; }
public ushort Queue { get; set; }
public PacketFragmentHeader() { }
public PacketFragmentHeader(BinaryReader payload)
{
Sequence = payload.ReadUInt32();
Id = payload.ReadUInt32();
Count = payload.ReadUInt16();
Size = payload.ReadUInt16();
Index = payload.ReadUInt16();
Queue = payload.ReadUInt16();
}
public byte[] GetRaw()
{
var headerHandle = GCHandle.Alloc(this, GCHandleType.Pinned);
try
{
byte[] bytes = new byte[Marshal.SizeOf(typeof(PacketFragmentHeader))];
Marshal.Copy(headerHandle.AddrOfPinnedObject(), bytes, 0, bytes.Length);
return bytes;
}
finally
{
headerHandle.Free();
}
}
}
}