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

37
include/server/Server.h Normal file
View File

@@ -0,0 +1,37 @@
#pragma once
#include <blitz/network/EnetServer.h>
#include <blitz/protocol/PacketHandler.h>
namespace blitz {
namespace server {
class Server {
public:
Server(std::uint16_t a_Port, std::shared_ptr<Nz::EnttWorld> a_World);
~Server();
network::EnetConnection* GetConnection(std::uint16_t a_PeerId);
void CloseConnection(std::uint16_t a_PeerId);
private:
void HandleConnect(network::EnetConnection&);
void HandleDisconnect(network::EnetConnection&);
struct Session {
network::EnetConnection* m_Connection;
std::vector<std::unique_ptr<protocol::PacketHandler>> m_Handlers;
};
EnttWorld m_World;
std::map<std::uint16_t, Session> m_Sessions;
network::EnetServer m_NetworkServer;
void RegisterHandlers(Session& session);
void RegisterSystems();
void CreateEntity(network::EnetConnection&);
};
} // namespace server
} // namespace blitz