2
0

PubSubWriter.hpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef ZT_CONTROLLER_PUBSUBWRITER_HPP
  2. #define ZT_CONTROLLER_PUBSUBWRITER_HPP
  3. #include <google/cloud/pubsub/publisher.h>
  4. #include <memory>
  5. #include <nlohmann/json.hpp>
  6. #include <string>
  7. namespace ZeroTier {
  8. class PubSubWriter {
  9. public:
  10. PubSubWriter(std::string project, std::string topic, std::string controller_id);
  11. virtual ~PubSubWriter();
  12. bool publishNetworkChange(const nlohmann::json& networkJson, const std::string& frontend = "");
  13. bool publishMemberChange(const nlohmann::json& memberJson, const std::string& frontend = "");
  14. bool publishStatusChange(
  15. std::string frontend,
  16. std::string network_id,
  17. std::string node_id,
  18. std::string os,
  19. std::string arch,
  20. std::string version,
  21. int64_t last_seen);
  22. protected:
  23. bool publishMessage(const std::string& payload, const std::string& frontend = "");
  24. private:
  25. std::string _controller_id;
  26. std::string _project;
  27. std::string _topic;
  28. std::shared_ptr<google::cloud::pubsub::Publisher> _publisher;
  29. };
  30. } // namespace ZeroTier
  31. #endif // ZT_CONTROLLER_PUBSUBWRITER_HPP