1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-16 07:06:30 +09:00

ConnectionLatencyUpdated message type added; WriteTime() ReadTime() added

This commit is contained in:
lidgren
2010-12-20 10:35:51 +00:00
parent 772d80835b
commit 330c5cf83e
11 changed files with 85 additions and 25 deletions

View File

@@ -465,6 +465,20 @@ namespace Lidgren.Network
return new IPEndPoint(address, port);
}
/// <summary>
/// Reads a value, in local time comparable to NetTime.Now, written using WriteTime()
/// Must have a connected sender
/// </summary>
public double ReadTime(bool highPrecision)
{
double remoteTime = (highPrecision ? ReadDouble() : (double)ReadSingle());
if (m_senderConnection == null)
throw new NetException("Cannot call ReadTime() on message without a connected sender (ie. unconnected messages)");
return remoteTime - m_senderConnection.m_remoteTimeOffset;
}
/// <summary>
/// Pads data with enough bits to reach a full byte. Decreases cpu usage for subsequent byte writes.
/// </summary>