namespace NeonTea.Quakeball.TeaNet.Packets { /// A packet for sending stuff over to connections. public abstract class Packet { /// Packet meta-information: Is this packet reliable. Set just before sending. public bool PacketIsReliable = true; /// Packet meta-information: Id of this packet. Set just before sending. public int PacketId; /// Size of this packet in bytes. Only available after the packet has been Read (when received) or Written (when sent). public int Size; /// Write any relevant information about this packet into the buffer. public abstract void Write(ByteBuffer buffer); /// Read and assign any relevant information about this packet from the buffer. public abstract void Read(ByteBuffer buffer); /// Make a shallow copy for this packet, copying any primitives but retaining any references to instances. public Packet ShallowCopy() { return (Packet)this.MemberwiseClone(); } } /// Defines something as writeable/readable by the buffer. Useful for creating abstractions within packets. public interface Serializable { void Write(ByteBuffer buffer); void Read(ByteBuffer buffer); } public enum PacketStage { Establishing = 0, Rejected = 1, Closed = 2, Ready = 3, } public enum ClosingReason { Unknown = 0, IncorrectVersion = 1, Timeout = 2, Manual = 3, } }