FactoryClient.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include <Network.h>
  3. #include <Klient.h>
  4. #include <Text.h>
  5. #include <Thread.h>
  6. #include <Critical.h>
  7. #include <VecN.h>
  8. #include <Either.h>
  9. #include <Punkt.h>
  10. #include "Entity.h"
  11. class FactoryClient : public Framework::ReferenceCounter
  12. {
  13. private:
  14. Network::SSLKlient* client;
  15. Network::Klient* foreground;
  16. Network::Klient* background;
  17. Network::NetworkReader* foregroundReader;
  18. Network::NetworkReader* backgroundReader;
  19. Framework::Critical cs;
  20. Framework::Text ip;
  21. int bgReaderUsage;
  22. int fgReaderUsage;
  23. void disconnect();
  24. void loadServerInfo();
  25. public:
  26. FactoryClient();
  27. ~FactoryClient();
  28. bool connect(Framework::Text ip, unsigned short sslPort);
  29. int ping();
  30. int status(Framework::Text name, Framework::Text secret);
  31. int join(Framework::Text name, Framework::Text &secret, unsigned short port);
  32. Network::NetworkReader* getNextForegroundMessage();
  33. Network::NetworkReader* getNextBackgroundMessage();
  34. void endMessageReading(bool bg);
  35. void sendPlayerAction(char* data, unsigned short length);
  36. void sendPlayerMovement(MovementFrame& frame);
  37. void entityAPIRequest(int entityId, char* message, unsigned short length);
  38. void chunkAPIRequest(Framework::Punkt center, char* message, unsigned short length);
  39. void inventoryAPIRequest(Framework::Either<int, Framework::VecN<int, 4>> target, char* message, unsigned short length);
  40. };