fully implement KeepAlive behavior

This commit is contained in:
2024-07-21 20:59:13 +02:00
parent 36a2e67ac4
commit 92a2e53036
25 changed files with 513 additions and 61 deletions

View File

@@ -2,7 +2,7 @@
#include <Nazara/Core/ThreadExt.hpp>
#include <Nazara/Network/ENetHost.hpp>
#include <blitz/network/EnetConnexion.h>
#include <blitz/network/EnetConnection.h>
#include <cstdint>
#include <map>
#include <thread>
@@ -17,24 +17,24 @@ class EnetServer : private NonCopyable {
void Destroy();
// void BroadcastPacket(const protocol::Packet& a_Packet, Nz::ENetPacketFlags a_Flags);
void CloseConnection(std::uint16_t a_PeerId);
EnetConnexion* GetConnexion(std::uint16_t a_PeerId);
EnetConnection* GetConnection(std::uint16_t a_PeerId);
NazaraSignal(OnClientConnect, EnetConnexion& /*a_Peer*/);
NazaraSignal(OnClientDisconnect, EnetConnexion& /*a_Peer*/);
NazaraSignal(OnClientDisconnectTimeout, EnetConnexion& /*a_Peer*/);
NazaraSignal(OnClientConnect, EnetConnection& /*a_Peer*/);
NazaraSignal(OnClientDisconnect, EnetConnection& /*a_Peer*/);
NazaraSignal(OnClientDisconnectTimeout, EnetConnection& /*a_Peer*/);
private:
void Update();
void WorkerThread();
void RemoveConnexion(std::uint16_t a_PeerId);
void RemoveConnection(std::uint16_t a_PeerId);
Nz::ENetHost m_Host;
bool m_Running;
std::thread m_Thread;
std::map<std::uint16_t, std::unique_ptr<EnetConnexion>> m_Connexion;
std::map<std::uint16_t, std::unique_ptr<EnetConnection>> m_Connections;
};
} // namespace network