Server.h 836 B

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