Add NetworkHost id and comparison operator
This commit is contained in:
@@ -77,6 +77,8 @@ void ENetDriver::Dispose()
|
||||
|
||||
_peer = nullptr;
|
||||
_host = nullptr;
|
||||
|
||||
LOG(Info, "ENet driver stopped!");
|
||||
}
|
||||
|
||||
bool ENetDriver::Listen()
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
struct FLAXENGINE_API NetworkHost
|
||||
{
|
||||
public:
|
||||
int HostId;
|
||||
NetworkConfig Config;
|
||||
INetworkDriver* NetworkDriver = nullptr;
|
||||
|
||||
@@ -32,5 +33,16 @@ public:
|
||||
// Calculate and return the buffer slice using previously calculated slice.
|
||||
return MessageBuffer + Config.MessageSize * messageId;
|
||||
}
|
||||
|
||||
public:
|
||||
FORCE_INLINE bool operator==(const NetworkHost& other) const
|
||||
{
|
||||
return HostId == other.HostId;
|
||||
}
|
||||
|
||||
FORCE_INLINE bool operator!=(const NetworkHost& other) const
|
||||
{
|
||||
return HostId != other.HostId;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ int NetworkManager::Initialize(const NetworkConfig& config)
|
||||
const int hostId = Hosts.Count();
|
||||
Hosts.Add(NetworkHost());
|
||||
NetworkHost& host = Hosts.Last();
|
||||
host.HostId = hostId;
|
||||
|
||||
// Initialize the host
|
||||
host.Initialize(config);
|
||||
@@ -41,6 +42,7 @@ void NetworkManager::Shutdown(const int hostId)
|
||||
ASSERT(Hosts[hostId].IsValid());
|
||||
NetworkHost& host = Hosts[hostId];
|
||||
host.Shutdown();
|
||||
Hosts.Remove(host);
|
||||
}
|
||||
|
||||
bool NetworkManager::Listen(const int hostId)
|
||||
|
||||
Reference in New Issue
Block a user