修改已知bug
This commit is contained in:
parent
84a1adbd80
commit
e41a7adc32
22
src/main.cpp
22
src/main.cpp
@ -4,6 +4,7 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
@ -15,7 +16,7 @@
|
|||||||
#include "tunnel_client.hpp"
|
#include "tunnel_client.hpp"
|
||||||
|
|
||||||
std::atomic<bool> g_running(true);
|
std::atomic<bool> g_running(true);
|
||||||
TunnelClient* g_tunnel_client = nullptr;
|
std::unique_ptr<TunnelClient> g_tunnel_client;
|
||||||
|
|
||||||
static void signal_handler(int signum)
|
static void signal_handler(int signum)
|
||||||
{
|
{
|
||||||
@ -65,15 +66,19 @@ int main()
|
|||||||
RTMPManager::start_all();
|
RTMPManager::start_all();
|
||||||
|
|
||||||
{
|
{
|
||||||
std::string vid = g_app_config.vehicle_id;
|
// 从配置里拿 VID(确保 AppConfig 有 vehicle_id 字段)
|
||||||
int local_http_port = 2980;
|
const std::string vid = g_app_config.vehicle_id;
|
||||||
|
const int local_http_port = 2980;
|
||||||
|
|
||||||
std::string tunnel_server = "ws://36.153.162.171:2088/tunnel";
|
// 建议也从 config 里读;这里先保留你的固定值
|
||||||
|
const std::string tunnel_server = "ws://36.153.162.171:2088/tunnel";
|
||||||
g_tunnel_client = new TunnelClient(vid, tunnel_server, local_http_port);
|
|
||||||
|
|
||||||
|
// 用 unique_ptr 管理生命周期
|
||||||
|
g_tunnel_client = std::make_unique<TunnelClient>(vid, tunnel_server, local_http_port);
|
||||||
g_tunnel_client->start();
|
g_tunnel_client->start();
|
||||||
LOG_INFO("[MAIN] TunnelClient started: %s", tunnel_server.c_str());
|
|
||||||
|
// 关键:LOG_INFO 只接收一个参数,所以拼接成一个字符串
|
||||||
|
LOG_INFO(("[MAIN] TunnelClient started: " + tunnel_server).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 启动 MQTT 线程
|
// 启动 MQTT 线程
|
||||||
@ -101,8 +106,7 @@ int main()
|
|||||||
if (g_tunnel_client)
|
if (g_tunnel_client)
|
||||||
{
|
{
|
||||||
g_tunnel_client->stop();
|
g_tunnel_client->stop();
|
||||||
delete g_tunnel_client;
|
g_tunnel_client.reset();
|
||||||
g_tunnel_client = nullptr;
|
|
||||||
LOG_INFO("[MAIN] TunnelClient stopped.");
|
LOG_INFO("[MAIN] TunnelClient stopped.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user