first commit
This commit is contained in:
parent
015b3e0985
commit
cec19302f8
@ -40,6 +40,8 @@ static void on_mqtt_message_received(const std::string &topic, const std::string
|
|||||||
}
|
}
|
||||||
|
|
||||||
int status = j["data"]["status"].get<int>();
|
int status = j["data"]["status"].get<int>();
|
||||||
|
std::string seqNo = j["seqNo"].get<std::string>();
|
||||||
|
bool success = true; // 标记是否操作成功
|
||||||
|
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
{
|
{
|
||||||
@ -74,7 +76,25 @@ static void on_mqtt_message_received(const std::string &topic, const std::string
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_WARN("[MQTT] video_down: unknown status value " + std::to_string(status));
|
LOG_WARN("[MQTT] video_down: unknown status value " + std::to_string(status));
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取当前时间 yyyyMMddHHmmssSSS
|
||||||
|
auto now = std::chrono::system_clock::now();
|
||||||
|
auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000;
|
||||||
|
std::time_t t = std::chrono::system_clock::to_time_t(now);
|
||||||
|
std::tm tm_now = *std::localtime(&t);
|
||||||
|
std::ostringstream time_ss;
|
||||||
|
time_ss << std::put_time(&tm_now, "%Y%m%d%H%M%S") << std::setw(3) << std::setfill('0') << millis.count();
|
||||||
|
|
||||||
|
nlohmann::json reply;
|
||||||
|
reply["time"] = time_ss.str();
|
||||||
|
reply["result"] = success ? 0 : 1;
|
||||||
|
reply["seqNo"] = seqNo;
|
||||||
|
|
||||||
|
// 发送应答
|
||||||
|
MQTTClientWrapper::publish(g_app_config.mqtt.topics.substream_down_ack, reply.dump());
|
||||||
|
LOG_INFO("[MQTT] Replied to video_down: " + reply.dump());
|
||||||
}
|
}
|
||||||
else if (topic == g_app_config.mqtt.topics.substream_down)
|
else if (topic == g_app_config.mqtt.topics.substream_down)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user