38 lines
864 B
C++
38 lines
864 B
C++
#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
|