1.添加图片注册和前后板主题图片上传;2.修改mdns连接方式
This commit is contained in:
44
FactoryTestTool/SourceCode/Network/mdns/MdnsServiceThread.h
Normal file
44
FactoryTestTool/SourceCode/Network/mdns/MdnsServiceThread.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <signal.h>
|
||||
|
||||
#include "mdns.h"
|
||||
|
||||
// 添加一个类来运行 mDNS 服务
|
||||
class MdnsServiceThread : public QThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MdnsServiceThread(const QString& hostname, const QString& serviceName, int servicePort, QObject* parent = nullptr)
|
||||
: QThread(parent),
|
||||
m_hostname(hostname),
|
||||
m_serviceName(serviceName),
|
||||
m_servicePort(servicePort) {}
|
||||
|
||||
void stop() {
|
||||
extern volatile sig_atomic_t running;
|
||||
running = 0; // 停止 mDNS 主循环
|
||||
m_running = false; // 设置运行标志为 false
|
||||
}
|
||||
|
||||
protected:
|
||||
void run() override {
|
||||
qDebug() << "Starting mDNS service...";
|
||||
extern volatile sig_atomic_t running; // 使用全局变量控制运行状态
|
||||
running = 1;
|
||||
|
||||
// 调用阻塞的 service_mdns 方法
|
||||
int result = service_mdns(m_hostname.toStdString().c_str(), m_serviceName.toStdString().c_str(), m_servicePort);
|
||||
if (result < 0) {
|
||||
qDebug() << "Failed to start mDNS service";
|
||||
}
|
||||
else {
|
||||
qDebug() << "mDNS service stopped";
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_hostname;
|
||||
QString m_serviceName;
|
||||
int m_servicePort;
|
||||
bool m_running = true; // 默认运行状态
|
||||
};
|
||||
Reference in New Issue
Block a user