| 197 | template<typename TImpl, |
| 198 | c_enable_if_t<std::is_base_of<T, TImpl>::value, int> = 0> |
| 199 | CStatus pubTopicValue(const std::string& topic, |
| 200 | const std::shared_ptr<TImpl>& value, |
| 201 | GMessagePushStrategy strategy) { |
| 202 | CGRAPH_FUNCTION_BEGIN |
| 203 | auto innerTopic = internal::PUB_SUB_PREFIX + topic; |
| 204 | auto result = pub_sub_message_map_.find(innerTopic); |
| 205 | if (result == pub_sub_message_map_.end()) { |
| 206 | CGRAPH_RETURN_ERROR_STATUS("no find [" + topic + "] topic"); |
| 207 | } |
| 208 | |
| 209 | auto& messageSet = result->second; |
| 210 | for (auto msg : messageSet) { |
| 211 | msg->send(value, strategy); // 给所有订阅的信息,一次发送消息 |
| 212 | } |
| 213 | CGRAPH_FUNCTION_END |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * 根据传入的 connId信息,来获取对应的message信息。仅针对传入智能指针的情况 |