X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fserver%2FServer.hpp;h=f81c9cea205b4918edfbb26e4da3c1357402baa4;hb=4bf20a032873db3fbb15182e5053284601b90a2f;hp=3bffafc29d2ada80307be32b5cab2269c49a6a65;hpb=10a310869c61cc52046e165f36ac9639fe9d0c69;p=blank.git diff --git a/src/server/Server.hpp b/src/server/Server.hpp index 3bffafc..f81c9ce 100644 --- a/src/server/Server.hpp +++ b/src/server/Server.hpp @@ -7,6 +7,7 @@ #include "../world/WorldManipulator.hpp" #include +#include #include #include @@ -14,6 +15,8 @@ namespace blank { class ChunkIndex; +class CLIContext; +class CommandService; class Model; class Player; class WorldSave; @@ -29,6 +32,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); @@ -48,7 +55,7 @@ public: void SetBlock(Chunk &, int, const Block &) override; /// for use by client connections when they receive a line from the player - void DispatchMessage(Player &, const std::string &); + 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); @@ -63,6 +70,7 @@ private: private: UDPsocket serv_sock; UDPpacket serv_pack; + SDLNet_SocketSet serv_set; std::list clients; World &world; @@ -71,6 +79,7 @@ private: const Model *player_model; CLI cli; + std::unique_ptr cmd_srv; };