Add NetworkManager::GetClient by uint32 clientId

This commit is contained in:
Wojtek Figat
2023-04-14 15:03:16 +02:00
parent b4d20e128b
commit a52b352bd9
2 changed files with 17 additions and 0 deletions

View File

@@ -236,6 +236,16 @@ NetworkClient* NetworkManager::GetClient(const NetworkConnection& connection)
return nullptr;
}
NetworkClient* NetworkManager::GetClient(uint32 clientId)
{
for (NetworkClient* client : Clients)
{
if (client->ClientId == clientId)
return client;
}
return nullptr;
}
bool NetworkManager::StartServer()
{
PROFILE_CPU();

View File

@@ -153,6 +153,13 @@ public:
/// <returns>Found client or null.</returns>
API_FUNCTION() static NetworkClient* GetClient(API_PARAM(Ref) const NetworkConnection& connection);
/// <summary>
/// Gets the network client with a given identifier. Returns null if failed to find it.
/// </summary>
/// <param name="clientId">Network client identifier (synchronized on all peers).</param>
/// <returns>Found client or null.</returns>
API_FUNCTION() static NetworkClient* GetClient(uint32 clientId);
public:
/// <summary>
/// Starts the network in server mode. Returns true if failed (eg. invalid config).