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