Rename *Host functions to *Peer functions

This commit is contained in:
2021-06-21 21:02:48 +02:00
parent 3a722acc62
commit 7692aaf547
2 changed files with 15 additions and 13 deletions
+11 -11
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#include "NetworkManager.h"
@@ -11,11 +11,11 @@
namespace
{
Array<NetworkPeer*, HeapAllocation> Hosts;
Array<NetworkPeer*, HeapAllocation> Peers;
uint32_t LastHostId = 0;
}
NetworkPeer* NetworkManager::CreateHost(const NetworkConfig& config)
NetworkPeer* NetworkManager::CreatePeer(const NetworkConfig& config)
{
// Validate the address for listen/connect
NetworkEndPoint endPoint = {};
@@ -23,8 +23,8 @@ NetworkPeer* NetworkManager::CreateHost(const NetworkConfig& config)
ASSERT(config.Address == String("any") || isValidEndPoint);
// Alloc new host
Hosts.Add(New<NetworkPeer>());
NetworkPeer* host = Hosts.Last();
Peers.Add(New<NetworkPeer>());
NetworkPeer* host = Peers.Last();
host->HostId = LastHostId++;
// Initialize the host
@@ -33,12 +33,12 @@ NetworkPeer* NetworkManager::CreateHost(const NetworkConfig& config)
return host;
}
void NetworkManager::ShutdownHost(NetworkPeer* host)
void NetworkManager::ShutdownPeer(NetworkPeer* peer)
{
ASSERT(host->IsValid());
host->Shutdown();
host->HostId = -1;
Hosts.Remove(host);
ASSERT(peer->IsValid());
peer->Shutdown();
peer->HostId = -1;
Peers.Remove(peer);
Delete(host);
Delete(peer);
}
+4 -2
View File
@@ -10,7 +10,9 @@ API_CLASS(Namespace="FlaxEngine.Networking", Static) class FLAXENGINE_API Networ
DECLARE_SCRIPTING_TYPE_NO_SPAWN(NetworkManager);
public:
API_FUNCTION() static NetworkPeer* CreateHost(const NetworkConfig& config);
API_FUNCTION() static void ShutdownHost(NetworkPeer* host);
API_FUNCTION()
static NetworkPeer* CreatePeer(const NetworkConfig& config);
API_FUNCTION()
static void ShutdownPeer(NetworkPeer* peer);
};