2020-08-05 18:50:28 +02:00
|
|
|
namespace NeonTea.Quakeball.TeaNet.Packets {
|
2020-08-05 03:21:04 +02:00
|
|
|
public abstract class Packet {
|
2020-08-05 18:50:28 +02:00
|
|
|
public bool Reliable = true;
|
|
|
|
public int Id;
|
2020-08-05 03:21:04 +02:00
|
|
|
|
|
|
|
public abstract void Write(ByteBuffer buffer);
|
|
|
|
public abstract void Read(ByteBuffer buffer);
|
2020-08-05 18:50:28 +02:00
|
|
|
|
|
|
|
public void ReadMeta(ByteBuffer buffer) {
|
|
|
|
Id = buffer.ReadInt();
|
|
|
|
Reliable = buffer.ReadBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void WriteMeta(ByteBuffer buffer) {
|
2020-08-05 20:38:37 +02:00
|
|
|
buffer.Write(Id);
|
|
|
|
buffer.Write(Reliable);
|
2020-08-05 18:50:28 +02:00
|
|
|
}
|
2020-08-05 03:21:04 +02:00
|
|
|
}
|
|
|
|
|
2020-08-05 20:33:22 +02:00
|
|
|
public interface Serializable {
|
|
|
|
void Write(ByteBuffer buffer);
|
|
|
|
void Read(ByteBuffer buffer);
|
|
|
|
}
|
|
|
|
|
2020-08-05 03:21:04 +02:00
|
|
|
public enum PacketStage {
|
|
|
|
Establishing = 0,
|
|
|
|
Rejected = 1,
|
|
|
|
Closed = 2,
|
|
|
|
Ready = 3,
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum ClosingReason {
|
|
|
|
Unknown = 0,
|
2020-08-05 18:50:28 +02:00
|
|
|
IncorrectVersion = 1,
|
2020-08-05 03:21:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|