X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fserver%2FServer.hpp;h=9b89ab1bbc94692a400c7a3a6eda0054ca98a161;hb=3185bad87c06739e4ec19b456c7158437ba9621f;hp=683d36254c76523a6ba5afddd84c2607ae204292;hpb=dbd214ac278019c20c883cbb76456b0b0fddc063;p=blank.git diff --git a/src/server/Server.hpp b/src/server/Server.hpp index 683d362..9b89ab1 100644 --- a/src/server/Server.hpp +++ b/src/server/Server.hpp @@ -2,6 +2,7 @@ #define BLANK_SERVER_SERVER_HPP #include "../app/Config.hpp" +#include "../shared/CLI.hpp" #include "../world/World.hpp" #include "../world/WorldManipulator.hpp" @@ -13,6 +14,7 @@ namespace blank { class ChunkIndex; +class CLIContext; class Model; class Player; class WorldSave; @@ -28,6 +30,10 @@ public: Server(const Config::Network &, World &, const World::Config &, const WorldSave &); ~Server(); + // wait for data to arrive for at most dt milliseconds + void Wait(int dt) noexcept; + // true if there's data waiting to be handled + bool Ready() noexcept; void Handle(); void Update(int dt); @@ -46,6 +52,9 @@ public: void SetBlock(Chunk &, int, const Block &) override; + /// for use by client connections when they receive a line from the player + void DispatchMessage(CLIContext &, const std::string &); + /// send message to all connected clients void DistributeMessage(std::uint8_t type, std::uint32_t ref, const std::string &msg); @@ -59,6 +68,7 @@ private: private: UDPsocket serv_sock; UDPpacket serv_pack; + SDLNet_SocketSet serv_set; std::list clients; World &world; @@ -66,6 +76,8 @@ private: const WorldSave &save; const Model *player_model; + CLI cli; + }; }