GameServer.cpp 949 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <iostream>
  2. #include "server/GameServer.h"
  3. #include "server/commands/ConsoleEditor.h"
  4. #include "server/commands/CommandManager.h"
  5. GameServer::GameServer(const Clock& tps) : tps(tps) {
  6. }
  7. void GameServer::tick() {
  8. }
  9. void GameServer::handleCommands(ServerCommands& serverCommands) {
  10. String s;
  11. while(ConsoleEditor::readCommand(s)) {
  12. commandManager.execute(serverCommands, s);
  13. }
  14. }
  15. void GameServer::onFullServerClientConnect(Client& client) {
  16. (void) client;
  17. std::cout << "full\n";
  18. }
  19. void GameServer::onClientConnect(Client& client) {
  20. (void) client;
  21. std::cout << "connected\n";
  22. }
  23. void GameServer::onClientPackage(Client& client, Packet& packet) {
  24. (void) client;
  25. String s;
  26. while(packet.hasData()) {
  27. s.append(packet.readU8());
  28. }
  29. std::cout << "Packet: " << s << "\n";
  30. }
  31. void GameServer::onClientDisconnect(Client& client) {
  32. (void) client;
  33. std::cout << "disconnected\n";
  34. }