FactoryClient.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #include <Critical.h>
  3. #include <Either.h>
  4. #include <Klient.h>
  5. #include <Network.h>
  6. #include <Punkt.h>
  7. #include <Text.h>
  8. #include <Thread.h>
  9. #include <VecN.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(
  32. Framework::Text name, Framework::Text& secret, unsigned short port);
  33. Network::NetworkReader* getNextForegroundMessage();
  34. Network::NetworkReader* getNextBackgroundMessage();
  35. void endMessageReading(bool bg);
  36. void sendPlayerAction(const char* data, unsigned short length);
  37. void sendPlayerMovement(MovementFrame& frame);
  38. void entityAPIRequest(
  39. int entityId, const char* message, unsigned short length);
  40. void blockAPIRequest(
  41. Vec3<int> pos, const char* message, unsigned short length);
  42. void blockAPIRequest(int dimensionId,
  43. Vec3<int> pos,
  44. const char* message,
  45. unsigned short length);
  46. void chunkAPIRequest(
  47. Framework::Punkt center, const char* message, unsigned short length);
  48. void dimensionAPIRequest(const char* message, unsigned short length);
  49. void inventoryAPIRequest(
  50. Framework::Either<int, Framework::VecN<int, 4>> target,
  51. const char* message,
  52. unsigned short length);
  53. void uiRequest(
  54. Framework::Text dialogId, const char* message, unsigned short length);
  55. void craftingUIMLRequest(int itemTypeId);
  56. void sendChatMessage(Framework::Text message);
  57. void chatAPIRequest(const char* data, unsigned short length);
  58. bool isConnected();
  59. void leaveGame();
  60. };