internal void OnPacketSent(double Time, NetPacket Packet) { WreckUtils.IncSeq(ref LocalSeq); Packet.TimeSent = TimeSent = Time; Packet.PacketNum = LocalSeq; }
public void SendPacket(NetPacket Packet, NetWreckClient Cli) { byte[] Arr = ByteArrayPool.Rent(MaxDataSize); Cli.OnPacketSent(Timestamp(), Packet); int Len = WreckUtils.Serialize(Packet, Arr, MaxDataSize); SendRaw(Arr, Len, Cli); ByteArrayPool.Return(Arr); }
internal bool OnPacketReceived(double Time, NetPacket Packet) { if (!WreckUtils.SeqGreater(Packet.PacketNum, RemoteSeq)) { return(false); } RemoteSeq = Packet.PacketNum; TimeReceived = Time; return(true); }
bool ReceivePacket(ref IPEndPoint Sender, out NetPacket Packet) { if (ReceiveRaw(ref Sender, out byte[] Raw)) { Packet = AllocPacket(); WreckUtils.Deserialize(Raw, ref Packet); if (!Packet.IsValid()) { DebugPrint("Dropping invalid packet"); FreePacket(Packet); Packet = null; return(false); } return(true); } Packet = null; return(false); }