ZeroTierOne/nonfree/controller/ControllerChangeNotifier.hpp
Grant Limberg 012443acfa
Some checks failed
/ build_macos (push) Has been cancelled
/ build_windows (push) Has been cancelled
/ Central Controller Build (push) Has been cancelled
/ build_ubuntu (push) Has been cancelled
/ multi-arch-docker (push) Has been cancelled
wire up pubsub notifications from controller to frontend
2025-09-08 16:01:50 -07:00

52 lines
No EOL
1.3 KiB
C++

#ifndef CONTROLLERCHANGENOTIFIER_HPP
#define CONTROLLERCHANGENOTIFIER_HPP
#include <memory>
#include <nlohmann/json.hpp>
#include <string>
namespace ZeroTier {
class PubSubWriter;
class ControllerChangeNotifier {
public:
virtual ~ControllerChangeNotifier() = default;
virtual void notifyNetworkChange(
const nlohmann::json& oldNetwork,
const nlohmann::json& newNetwork,
const std::string& frontend = "") = 0;
virtual void notifyMemberChange(
const nlohmann::json& oldMember,
const nlohmann::json newMember,
const std::string& frontend = "") = 0;
};
class PubSubChangeNotifier : public ControllerChangeNotifier {
public:
PubSubChangeNotifier(std::string controllerID, std::string project);
virtual ~PubSubChangeNotifier();
virtual void notifyNetworkChange(
const nlohmann::json& oldNetwork,
const nlohmann::json& newNetwork,
const std::string& frontend = "") override;
virtual void notifyMemberChange(
const nlohmann::json& oldMember,
const nlohmann::json newMember,
const std::string& frontend = "") override;
private:
std::shared_ptr<PubSubWriter> _cv1networkChangeWriter;
std::shared_ptr<PubSubWriter> _cv1memberChangeWriter;
std::shared_ptr<PubSubWriter> _cv2networkChangeWriter;
std::shared_ptr<PubSubWriter> _cv2memberChangeWriter;
};
} // namespace ZeroTier
#endif // CONTROLLERCHANGENOTIFIER_HPP