GameServer.cpp 1.0 KB

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