FactoryClient.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. int bgReaderUsage;
  21. int fgReaderUsage;
  22. void disconnect();
  23. public:
  24. FactoryClient();
  25. ~FactoryClient();
  26. bool connect(Text ip, short port, int accountId, Text secret);
  27. Network::NetworkReader* getNextForegroundMessage();
  28. Network::NetworkReader* getNextBackgroundMessage();
  29. void endMessageReading(bool bg);
  30. void sendPlayerAction(char* data, unsigned short length);
  31. void sendPlayerMovement(MovementFrame& frame);
  32. void entityAPIRequest(int entityId, char* message, unsigned short length);
  33. void chunkAPIRequest(Framework::Punkt center, char* message, unsigned short length);
  34. void inventoryAPIRequest(Framework::Either<int, Framework::VecN<int, 4>> target, char* message, unsigned short length);
  35. };