GameClient.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #include <Array.h>
  3. #include <Critical.h>
  4. #include <InMemoryBuffer.h>
  5. #include <Thread.h>
  6. class Player;
  7. class FCKlient;
  8. class NetworkMessage;
  9. class GameClient : public Framework::Thread
  10. {
  11. private:
  12. Player* zPlayer;
  13. FCKlient* client;
  14. Framework::Critical background;
  15. Framework::Critical foreground;
  16. Framework::Critical other;
  17. Framework::RCArray<Framework::InMemoryBuffer> requests;
  18. Framework::RCArray<NetworkMessage> backgroundQueue;
  19. Framework::RCArray<NetworkMessage> foregroundQueue;
  20. Framework::Synchronizer foregroundQueueSync;
  21. Framework::Synchronizer backgroundQueueSync;
  22. Framework::Critical queueCs;
  23. Framework::Synchronizer emptyForegroundQueueSync;
  24. Framework::Synchronizer emptyBackgroundQueueSync;
  25. int viewDistance;
  26. bool first;
  27. bool online;
  28. bool finished;
  29. bool backgroundFinished;
  30. bool foregroundFinished;
  31. public:
  32. GameClient(Player* zPlayer, FCKlient* client);
  33. ~GameClient();
  34. void thread() override;
  35. void reply();
  36. void logout();
  37. void addMessage(Framework::StreamReader* reader);
  38. bool isOnline() const;
  39. void sendResponse(NetworkMessage* response);
  40. Player* zEntity() const;
  41. void sendTypes();
  42. class Message
  43. {
  44. public:
  45. inline static const unsigned char TERMINATE = 1;
  46. inline static const unsigned char WORLD_UPDATE = 2;
  47. inline static const unsigned char API_MESSAGE = 3;
  48. inline static const unsigned char POSITION_UPDATE = 4;
  49. };
  50. };