Skip to content

Commit ca5b3a8

Browse files
jeffreyrainy0xFA11
andauthored
fix: cleaning up connected clients upon shutdown [MTT-1573] (backport #1945) (#1949)
* 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 * Update CHANGELOG.md Co-authored-by: Fatih Mar <[email protected]>
1 parent e052cc8 commit ca5b3a8

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Additional documentation and release notes are available at [Multiplayer Documen
88

99
### Fixed
1010

11-
- Fixed: Hosting again after failing to host now works correctly
12-
13-
- Fixed: NetworkHide followed by NetworkShow on the same frame works correctly (#1940)
11+
- Fixed Hosting again after failing to host now works correctly (#1938)
12+
- Fixed NetworkManager to cleanup connected client lists after stopping (#1945)
13+
- Fixed NetworkHide followed by NetworkShow on the same frame works correctly (#1940)
1414

1515
## [1.0.0-pre.8] - 2022-04-27
1616

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)