Main.cpp 690 B

1234567891011121314151617181920212223242526272829303132
  1. #include <iostream>
  2. #include <array>
  3. #include "Socket.h"
  4. #include "Client.h"
  5. #include "Game.h"
  6. int main() {
  7. Socket socket;
  8. if(socket.start(4455)) {
  9. return 0;
  10. }
  11. std::array<Client, 20> clients;
  12. while(true) {
  13. int clientId = socket.waitForClients(100);
  14. if(clientId != -1) {
  15. for(Client& client : clients) {
  16. if(client.isFree()) {
  17. client.start(clientId);
  18. break;
  19. }
  20. }
  21. std::cout << "client added" << "\n";
  22. }
  23. char buffer[256];
  24. if(socket.readConsole(buffer, 256, 100)) {
  25. break;
  26. }
  27. }
  28. return 0;
  29. }