1
This commit is contained in:
parent
6d606c618e
commit
643b64d828
@ -20,21 +20,17 @@ static void send_heartbeat()
|
||||
{
|
||||
if (!mqtt_client || !mqtt_client->isConnected()) return;
|
||||
|
||||
nlohmann::json hb_data;
|
||||
hb_data["time"] = Logger::get_current_time_utc8();
|
||||
hb_data["status"] = g_streaming ? 0 : 2;
|
||||
// 获取当前时间戳(13位毫秒)
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count();
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(g_dispatch_id_mutex);
|
||||
hb_data["dispatchId"] = g_streaming ? g_dispatch_id : "";
|
||||
}
|
||||
g_streaming.store(RTMPManager::is_any_streaming());
|
||||
|
||||
nlohmann::json msg;
|
||||
msg["data"] = hb_data;
|
||||
msg["isEnc"] = 0;
|
||||
msg["type"] = 0;
|
||||
nlohmann::json hb;
|
||||
hb["timestamp"] = ms;
|
||||
hb["status"] = g_streaming ? 1 : 0; // 0:等待中,1:推流中
|
||||
|
||||
mqtt_client->publish(g_app_config.mqtt.topics.heartbeat_up, msg.dump());
|
||||
mqtt_client->publish(g_app_config.mqtt.topics.heartbeat_up, hb.dump());
|
||||
}
|
||||
|
||||
// MQTT 回调
|
||||
|
||||
Loading…
Reference in New Issue
Block a user