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

38 lines
975 B

5 years ago
  1. #ifndef MW_MAP_I_H
  2. #define MW_MAP_I_H
  3. #include <Ice/Ice.h>
  4. #include <MW.h>
  5. #include <set>
  6. class MWMapCallbackAdapter
  7. {
  8. public:
  9. virtual void init(Ice::StringSeq) = 0;
  10. virtual void join(const std::shared_ptr<MW::UserJoinedEvent>&) = 0;
  11. virtual void leave(const std::shared_ptr<MW::UserLeftEvent>&) = 0;
  12. virtual void send(const std::shared_ptr<MW::PositionEvent>&) = 0;
  13. };
  14. class MWMap
  15. {
  16. public:
  17. MWMap(bool trace, const std::shared_ptr<Ice::Logger>& logger);
  18. void reserve(const std::string&);
  19. void unreserve(const std::string&);
  20. void join(const std::string&, const std::shared_ptr<MWMapCallbackAdapter>&);
  21. void leave(const std::string&);
  22. long long send(const std::string&, std::string);
  23. private:
  24. using MWMapCallbackMap = std::map<std::string, std::shared_ptr<MWMapCallbackAdapter>>;
  25. MWMapCallbackMap _members;
  26. std::set<std::string> _reserved;
  27. std::mutex _mutex;
  28. const bool _trace;
  29. const std::shared_ptr<Ice::Logger> _logger;
  30. };
  31. #endif