MqttTopic.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "MqttTopic.h"
  2. #include "memepp/string_def.hpp"
  3. mqtt::MqttTopic::MqttTopic(const std::string& topic, const std::string& stationId)
  4. {
  5. this->topic_ = topic;
  6. this->stationId_ = stationId;
  7. }
  8. mqtt::MqttTopic::MqttTopic(const std::string& topic, const std::string& stationId, bool hasReply)
  9. {
  10. this->topic_ = topic;
  11. this->stationId_ = stationId;
  12. this->hasReply_ = hasReply;
  13. }
  14. mqtt::MqttTopic::MqttTopic(const std::string& topic, const std::string& stationId, bool hasReply,
  15. bool is_gateway_active)
  16. {
  17. this->topic_ = topic;
  18. this->stationId_ = stationId;
  19. this->hasReply_ = hasReply;
  20. this->is_gateway_active_ = is_gateway_active;
  21. }
  22. memepp::string mqtt::MqttTopic::get_subscribe_topic() const
  23. {
  24. if (this->topic_ == "/data/up-call") {
  25. return ("/hyper/itv_" + this->stationId_ + this->topic_ + "reply").c_str();
  26. }
  27. else if (this->topic_=="bridge") {
  28. return ("/dis/interface/point/bridge/respone/" + stationId_).c_str();
  29. }
  30. else {
  31. return ("/hyper/itv_" + this->stationId_ + this->topic_ + "_reply").c_str();
  32. }
  33. }
  34. memepp::string mqtt::MqttTopic::get_publish_topic() const
  35. {
  36. if (this->topic_ == "bridge") {
  37. return ("/dis/interface/point/bridge/request/" + stationId_).c_str();
  38. }
  39. else {
  40. return ("/hyper/itv_" + this->stationId_ + this->topic_).c_str();
  41. }
  42. }