quakeball/Assets/Scripts/Networking/Packets/PingPckt.cs

31 lines
948 B
C#
Raw Normal View History

2020-08-08 02:35:19 +02:00
using NeonTea.Quakeball.TeaNet.Packets;
namespace NeonTea.Quakeball.Networking.Packets {
public class PingPckt : Packet {
public byte Identifier;
public bool ServerReceived = false;
public bool ClientReceived = false;
public PingPckt() { }
public PingPckt(byte identifier) {
Identifier = identifier;
}
public override void Read(ByteBuffer buffer) {
Identifier = buffer.Read();
byte result = buffer.Read();
ServerReceived = (result & 1) == 1;
ClientReceived = (result & 2) == 1;
}
public override void Write(ByteBuffer buffer) {
buffer.Write(Identifier);
byte serverFlag = ServerReceived ? (byte)1 : (byte)0;
byte clientFlag = ClientReceived ? (byte)2 : (byte)0;
byte total = (byte)(serverFlag | clientFlag);
buffer.Write(total);
}
}
}