diff --git a/Assets/Mirror/Core/NetworkConnection.cs b/Assets/Mirror/Core/NetworkConnection.cs index 851beaea0..4c1a77505 100644 --- a/Assets/Mirror/Core/NetworkConnection.cs +++ b/Assets/Mirror/Core/NetworkConnection.cs @@ -61,6 +61,19 @@ public abstract class NetworkConnection // different connections. public double remoteTimeStamp { get; internal set; } + // unreliable delta compression: we need to keep track of which identities were in which sent batch @ timestamp. + // so when the ack comes back, we know which identities were acked. + // this is necessary since we sync per-identity not per-worldstate. + internal readonly SortedList> identityTicks = new SortedList>(); + + // unreliable delta compression: we need to know the last acked state for each connection. + // currently we sync one entity at a time in batches, so we also need to store acks for one at a time. + // + // TODO remove old when unspawned + readonly Dictionary identityAcks = new Dictionary(); + + // + internal NetworkConnection() { // set lastTime to current time when creating connection to make diff --git a/Assets/Mirror/Core/NetworkServer.cs b/Assets/Mirror/Core/NetworkServer.cs index e6bcb1cfd..e49157fbc 100644 --- a/Assets/Mirror/Core/NetworkServer.cs +++ b/Assets/Mirror/Core/NetworkServer.cs @@ -1986,6 +1986,10 @@ static void BroadcastToConnection(NetworkConnectionToClient connection) payload = serialization.ToArraySegment() }; connection.Send(message, Channels.Unreliable); + + // keep track of which entities we sent to the connection on this tick. + // so when the connection sends back an ack, we know which entities were acked. + AckDeltaCompression.TrackIdentityAtTick(NetworkTime.localTime, identity.netId, connection.identityTicks, tickHistorySize); } } // spawned list should have no null entries because we