Server.h 659 B

123456789101112131415161718192021222324252627282930
  1. #ifndef SERVER_H
  2. #define SERVER_H
  3. #include <thread>
  4. #include <atomic>
  5. #include "server/network/Socket.h"
  6. #include "server/GameServer.h"
  7. class Server final {
  8. public:
  9. Server(const Socket& connectionListener, u16 maxClients, GameServer& gameServer);
  10. ~Server();
  11. Server(const Server& other) = delete;
  12. Server& operator=(const Server& other) = delete;
  13. Server(Server&& other) = delete;
  14. Server& operator=(Server&& other) = delete;
  15. void start();
  16. private:
  17. void listenForClients() const;
  18. const Socket& connectionListener;
  19. GameServer gameServer;
  20. std::atomic_bool running;
  21. std::thread listenerThread;
  22. };
  23. #endif