Server.h 793 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef SERVER_H
  2. #define SERVER_H
  3. #include "common/enet/enet.h"
  4. #include "common/utils/Types.h"
  5. #include "server/GameServer.h"
  6. #include "common/utils/Array.h"
  7. #include "server/network/Client.h"
  8. class Server final {
  9. public:
  10. Server(u16 port);
  11. ~Server();
  12. Server(const Server&) = delete;
  13. Server& operator=(const Server&) = delete;
  14. Server(Server&&) = delete;
  15. Server& operator=(Server&&) = delete;
  16. bool hasError() const;
  17. void consumeEvents(GameServer& gameServer);
  18. private:
  19. void onConnect(ENetEvent& event, GameServer& gameServer);
  20. void onPackage(ENetEvent& event, GameServer& gameServer);
  21. void onDisconnect(ENetEvent& event, GameServer& gameServer);
  22. uint getFreeIndex() const;
  23. ENetHost* server;
  24. Array<Client, 50> clients;
  25. };
  26. #endif