[StructLayout(LayoutKind.Sequential, Pack = 1)]
public class Packet
{
/// <summary>
/// Type of packet.
/// </summary>
public enum TypeID : byte
{
Account = 0x00,
Character = 0x01,
Speech = 0x02,
Movement = 0x03,
Server = 0x04,
Utility = 0x09
}
/// <summary>
/// Constructor.
/// </summary>
public Packet()
{
ID = 0xff;
SubID = 0xff;
}
/// <summary>
/// Returns the ID of a byte array destined to be converted to a packet.
/// </summary>
/// <param name="Data"></param>
/// <returns></returns>
public static byte GetID(byte[] Data)
{
return Data[0];
}
/// <summary>
/// Returns the Sub ID of a byte array destined to be converted to a packet.
/// </summary>
/// <param name="Data"></param>
/// <returns></returns>
public static byte GetSubID(byte[] Data)
{
return Data[1];
}
/// <summary>
/// The type of packet.
/// </summary>
public byte ID;
/// <summary>
/// The sub-type of packet.
/// </summary>
public byte SubID;
/// <summary>
/// The total size, in bytes, of the packet.
/// </summary>
public UInt32 Size;
/// <summary>
/// Connected client that sent this packet
/// </summary>
public ConnectedClient Client;
}