Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Additional documentation and release notes are available at [Multiplayer Documen

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

- Fixed: NetworkManager properly cleaning up its clientlists upon shutdown (#1945)

Comment thread
0xFA11 marked this conversation as resolved.
Outdated
- Fixed: NetworkHide followed by NetworkShow on the same frame works correctly (#1940)

## [1.0.0-pre.8] - 2022-04-27
Expand Down
19 changes: 13 additions & 6 deletions com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -765,12 +765,7 @@ private void Initialize(bool server)
#endif
LocalClientId = ulong.MaxValue;

PendingClients.Clear();
m_ConnectedClients.Clear();
m_ConnectedClientsList.Clear();
m_ConnectedClientIds.Clear();
LocalClient = null;
NetworkObject.OrphanChildren.Clear();
ClearClients();

// Create spawn manager instance
SpawnManager = new NetworkSpawnManager(this);
Expand Down Expand Up @@ -862,6 +857,16 @@ private void Initialize(bool server)
NetworkConfig.NetworkTransport.Initialize(this);
}

private void ClearClients()
{
PendingClients.Clear();
m_ConnectedClients.Clear();
m_ConnectedClientsList.Clear();
m_ConnectedClientIds.Clear();
LocalClient = null;
NetworkObject.OrphanChildren.Clear();
}

/// <summary>
/// Starts a server
/// </summary>
Expand Down Expand Up @@ -1301,6 +1306,8 @@ internal void ShutdownInternal()
IsListening = false;
m_ShuttingDown = false;
m_StopProcessingMessages = false;

ClearClients();
Copy link
Copy Markdown
Contributor

@0xFA11 0xFA11 May 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to answer your question, I'd like to ask a question here. wouldn't this change behavior such that connectedclients list(s) would be empty after stophost/client/server (aka shutdown) instead of (previously) containing stale data until we call Initialize() again?
I think that's the fix we're going for here with the JIRA ticket & this PR.
so, a changelog entry saying something like, "cleanup client lists on stophost/client/server" would be useful to know I think.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. done.

}

// INetworkUpdateSystem
Expand Down