fully implement KeepAlive behavior
This commit is contained in:
37
include/server/Server.h
Normal file
37
include/server/Server.h
Normal 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
|
||||
Reference in New Issue
Block a user