You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Communication.h 1.7 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef COMMUNICATION_H
  2. #define COMMUNICATION_H
  3. #include "Message2Server.pb.h"
  4. #include "Message2Clients.pb.h"
  5. #include "MessageType.pb.h"
  6. #include "Services.grpc.pb.h"
  7. #include "Services.pb.h"
  8. #include <grpcpp/grpcpp.h>
  9. #include "structures.h"
  10. #include <thread>
  11. #include <mutex>
  12. #include <queue>
  13. #include "ConcurrentQueue.hpp"
  14. class Logic;
  15. class Communication
  16. {
  17. public:
  18. Communication(std::string sIP, std::string sPort);
  19. ~Communication()
  20. {
  21. }
  22. bool Move(int64_t time, double angle, int64_t playerID);
  23. bool PickProp(THUAI6::PropType prop, int64_t playerID);
  24. bool UseProp(int64_t playerID);
  25. bool UseSkill(int64_t playerID);
  26. std::optional<std::pair<int64_t, std::string>> GetMessage();
  27. bool HaveMessage();
  28. bool SendMessage(int64_t toID, std::string message, int64_t playerID);
  29. bool Escape(int64_t playerID);
  30. bool StartFixMachine(int64_t playerID);
  31. bool EndFixMachine(int64_t playerID);
  32. bool StartSaveHuman(int64_t playerID);
  33. bool EndSaveHuman(int64_t playerID);
  34. bool Attack(double angle, int64_t playerID);
  35. bool CarryHuman(int64_t playerID);
  36. bool ReleaseHuman(int64_t playerID);
  37. bool HangHuman(int64_t playerID);
  38. bool TryConnection(int64_t playerID);
  39. protobuf::MessageToClient GetMessage2Client();
  40. bool HaveMessage2Client();
  41. void AddPlayer(int64_t playerID, THUAI6::PlayerType playerType, THUAI6::HumanType humanType, THUAI6::ButcherType butcherType);
  42. void ReadMessage(int64_t playerID);
  43. private:
  44. std::unique_ptr<protobuf::AvailableService::Stub> THUAI6Stub;
  45. bool haveNewMessage = false;
  46. protobuf::MessageToClient message2Client;
  47. ConcurrentQueue<std::pair<int64_t, std::string>> messageQueue;
  48. };
  49. #endif