diff --git a/Documentation/Documentation.chm b/Documentation/Documentation.chm index 97e855e..e3b9979 100644 Binary files a/Documentation/Documentation.chm and b/Documentation/Documentation.chm differ diff --git a/Lidgren.Network/NetConnection.Handshake.cs b/Lidgren.Network/NetConnection.Handshake.cs index fa63d22..a9fee3e 100644 --- a/Lidgren.Network/NetConnection.Handshake.cs +++ b/Lidgren.Network/NetConnection.Handshake.cs @@ -138,7 +138,7 @@ namespace Lidgren.Network om.m_messageType = NetMessageType.ConnectionEstablished; m_peer.SendLibrary(om, m_remoteEndpoint); - m_sentPingTime = (float)NetTime.Now - (m_peerConfiguration.PingInterval / 2.0f); // delay ping for a little while + InitializePing(); if (m_status != NetConnectionStatus.Connected) SetStatus(NetConnectionStatus.Connected, "Connected to " + NetUtility.ToHexString(m_remoteUniqueIdentifier)); } @@ -285,7 +285,7 @@ namespace Lidgren.Network case NetConnectionStatus.RespondedConnect: // awesome m_peer.AcceptConnection(this); - m_sentPingTime = (float)NetTime.Now - (m_peerConfiguration.PingInterval / 2.0f); // delay ping for a little while + InitializePing(); SetStatus(NetConnectionStatus.Connected, "Connected to " + NetUtility.ToHexString(m_remoteUniqueIdentifier)); return; } diff --git a/Lidgren.Network/NetConnection.Latency.cs b/Lidgren.Network/NetConnection.Latency.cs index d8ad4ac..66e86d2 100644 --- a/Lidgren.Network/NetConnection.Latency.cs +++ b/Lidgren.Network/NetConnection.Latency.cs @@ -14,6 +14,14 @@ namespace Lidgren.Network /// public float AverageRoundtripTime { get { return m_averageRoundtripTime; } } + internal void InitializePing() + { + // randomize ping sent time (0.25 - 1.0 x ping interval) + m_sentPingTime = (float)NetTime.Now; + m_sentPingTime -= (m_peerConfiguration.PingInterval * 0.25f); // delay ping for a little while + m_sentPingTime -= (NetRandom.Instance.NextSingle() * (m_peerConfiguration.PingInterval * 0.75f)); + } + internal void SendPing() { m_peer.VerifyNetworkThread(); diff --git a/Lidgren.Network/NetQueue.cs b/Lidgren.Network/NetQueue.cs index d21128e..4636953 100644 --- a/Lidgren.Network/NetQueue.cs +++ b/Lidgren.Network/NetQueue.cs @@ -156,6 +156,9 @@ namespace Lidgren.Network } } + /// + /// Returns default(T) if queue is empty + /// public T TryPeek(int offset) { if (m_size == 0) diff --git a/Samples/LibraryTestSamples/DurableSample/DurableServer/Program.cs b/Samples/LibraryTestSamples/DurableSample/DurableServer/Program.cs index 2b6ae7a..16b80cf 100644 --- a/Samples/LibraryTestSamples/DurableSample/DurableServer/Program.cs +++ b/Samples/LibraryTestSamples/DurableSample/DurableServer/Program.cs @@ -144,6 +144,7 @@ namespace DurableServer else { StringBuilder bdr = new StringBuilder(); + bdr.AppendLine("Uptime: " + (NetTime.ToReadable(NetTime.Now))); bdr.Append(Server.Statistics.ToString()); bdr.Append(Server.Connections[0].Statistics.ToString()); bdr.AppendLine("RECEIVED Reliable ordered: " +