From: JamJar00 Date: Thu, 12 May 2016 21:08:01 +0000 (+0100) Subject: Added aknowledged flag X-Git-Tag: 1.0.0~162 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=642d2838eaaec6d44c241c34a2e874d62482d003;p=rhonda%2Fimpostor.hazel.git Added aknowledged flag --- diff --git a/Hazel/UdpConnection.Reliable.cs b/Hazel/UdpConnection.Reliable.cs index fd53ab7..d69b393 100644 --- a/Hazel/UdpConnection.Reliable.cs +++ b/Hazel/UdpConnection.Reliable.cs @@ -56,8 +56,9 @@ namespace Hazel { public byte[] Data; public Timer Timer; - public int LastTimeout; + public volatile int LastTimeout; public Action AckCallback; + public volatile bool Acknowledged = false; public Packet(byte[] data, Action resendAction, int timeout, Action ackCallback) { @@ -103,7 +104,10 @@ namespace Hazel //Double packet timeout lock (p.Timer) - p.Timer.Change(p.LastTimeout *= 2, Timeout.Infinite); + { + if (!p.Acknowledged) + p.Timer.Change(p.LastTimeout *= 2, Timeout.Infinite); + } Trace.WriteLine("Resend."); }, @@ -176,6 +180,8 @@ namespace Hazel { Packet packet = reliableDataPacketsSent[id]; + packet.Acknowledged = true; + lock (packet.Timer) packet.Timer.Dispose();