Skip to content
Merged
Changes from 1 commit
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
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