Skip to content

Commit 4a5c86f

Browse files
jeffreyrainy0xFA11
andauthored
fix: cleaning up connected clients upon shutdown [MTT-1573] (#1945)
* chore: cleaning up connected clients upon shutdown [MTT-1573] * chore: cleaning up connected clients upon shutdown [MTT-1573] changelog * Update com.unity.netcode.gameobjects/CHANGELOG.md Co-authored-by: Fatih Mar <mfatihmar@gmail.com>
1 parent ad68997 commit 4a5c86f

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
1010

1111
- Fixed: Hosting again after failing to host now works correctly
1212

13+
- Fixed NetworkManager to cleanup connected client lists after stopping (#1945)
1314
- Fixed: NetworkHide followed by NetworkShow on the same frame works correctly (#1940)
1415

1516
## [1.0.0-pre.8] - 2022-04-27

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -765,12 +765,7 @@ private void Initialize(bool server)
765765
#endif
766766
LocalClientId = ulong.MaxValue;
767767

768-
PendingClients.Clear();
769-
m_ConnectedClients.Clear();
770-
m_ConnectedClientsList.Clear();
771-
m_ConnectedClientIds.Clear();
772-
LocalClient = null;
773-
NetworkObject.OrphanChildren.Clear();
768+
ClearClients();
774769

775770
// Create spawn manager instance
776771
SpawnManager = new NetworkSpawnManager(this);
@@ -862,6 +857,16 @@ private void Initialize(bool server)
862857
NetworkConfig.NetworkTransport.Initialize(this);
863858
}
864859

860+
private void ClearClients()
861+
{
862+
PendingClients.Clear();
863+
m_ConnectedClients.Clear();
864+
m_ConnectedClientsList.Clear();
865+
m_ConnectedClientIds.Clear();
866+
LocalClient = null;
867+
NetworkObject.OrphanChildren.Clear();
868+
}
869+
865870
/// <summary>
866871
/// Starts a server
867872
/// </summary>
@@ -1301,6 +1306,8 @@ internal void ShutdownInternal()
13011306
IsListening = false;
13021307
m_ShuttingDown = false;
13031308
m_StopProcessingMessages = false;
1309+
1310+
ClearClients();
13041311
}
13051312

13061313
// INetworkUpdateSystem

0 commit comments

Comments
 (0)