perf: NetworkServer.Update: separate connections update loop moved into the main loop. now there is only one connections loop anymore.

This commit is contained in:
vis2k 2021-03-04 19:43:19 +08:00
parent 5775a36e49
commit aa357dc58b

View File

@ -479,8 +479,7 @@ internal static void NetworkLateUpdate()
// only process spawned & connections if active
if (active)
{
// for each READY connection:
// pull in UpdateVarsMessage for each entity it observes
// go through all connections
foreach (NetworkConnectionToClient connection in connections.Values)
{
// check for inactivity
@ -493,6 +492,8 @@ internal static void NetworkLateUpdate()
}
// has this connection joined the world yet?
// for each READY connection:
// pull in UpdateVarsMessage for each entity it observes
if (connection.isReady)
{
// for each entity that this connection is seeing
@ -584,6 +585,9 @@ internal static void NetworkLateUpdate()
else Debug.LogWarning("Found 'null' entry in observing list for connectionId=" + connection.connectionId + ". Please call NetworkServer.Destroy to destroy networked objects. Don't use GameObject.Destroy.");
}
}
// update connection to flush out batched messages
connection.Update();
}
// return serialized writers to pool, clear set
@ -613,13 +617,6 @@ internal static void NetworkLateUpdate()
identity.ClearAllComponentsDirtyBits();
}
}
// update all connections to send out batched messages in interval
// TODO move this into the above foreach
foreach (NetworkConnectionToClient conn in connections.Values)
{
conn.Update();
}
}
// process all incoming messages after updating the world