Fusion.Engine.Server.SnapshotQueue.GetLag C# (CSharp) Method

GetLag() public method

Gets time lag between client and server. Sum???
public GetLag ( uint clientSnapshotID, GameTime currentGameTime ) : float
clientSnapshotID uint
currentGameTime Fusion.Engine.Common.GameTime
return float
		public float GetLag ( uint clientSnapshotID, GameTime currentGameTime)
		{
			foreach ( var snapshot in queue ) {
				if (snapshot.Frame==clientSnapshotID) {
					var lag = currentGameTime.Total - snapshot.Timestamp;

					return Math.Min(1, (float)lag.TotalSeconds );
				}
			}

			return 1;
		}

Usage Example

		/// <summary>
		/// 
		/// </summary>
		/// <param name="msg"></param>
		void DispatchUserCommand ( GameTime gameTime, SnapshotQueue queue, NetIncomingMessage msg )
		{	
			var snapshotID	=	msg.ReadUInt32();
			var commandID	=	msg.ReadUInt32();
			var size		=	msg.ReadInt32();

			var data		=	msg.ReadBytes( size );

			//	we got user command and (command count=1)
			//	this means that client receives snapshot:
			if (msg.SenderConnection.GetCommandCount()==1) {
				ClientActivated( msg.SenderConnection.GetHailGuid() );
			}

			//	do not feed server with empty command.
			if (data.Length>0) {
				FeedCommand( msg.SenderConnection.GetHailGuid(), data, commandID, queue.GetLag(snapshotID, gameTime) );
			}

			//	set snapshot request when command get.
			msg.SenderConnection.SetRequestSnapshot( snapshotID, commandID );
		}