|
|
@@ -1,39 +1,39 @@
|
|
|
-#include "fileserver.h"
|
|
|
+#include "httpserver.h"
|
|
|
#include "logger.h"
|
|
|
#include <fstream>
|
|
|
#include <QJsonObject>
|
|
|
#include <QJsonDocument>
|
|
|
#include <QDir>
|
|
|
|
|
|
-FileServer::FileServer(QObject *parent)
|
|
|
+HttpServer::HttpServer(QObject *parent)
|
|
|
: QObject{parent}
|
|
|
{
|
|
|
moveToThread(&m_thread);
|
|
|
- connect(&m_thread, &QThread::started, this, &FileServer::run_hhttp_sever);
|
|
|
+ connect(&m_thread, &QThread::started, this, &HttpServer::run_hhttp_sever);
|
|
|
run("0.0.0.0", 18000);
|
|
|
}
|
|
|
|
|
|
-FileServer::~FileServer()
|
|
|
+HttpServer::~HttpServer()
|
|
|
{
|
|
|
stop();
|
|
|
}
|
|
|
|
|
|
-std::string FileServer::addr() const
|
|
|
+std::string HttpServer::addr() const
|
|
|
{
|
|
|
return m_addr;
|
|
|
}
|
|
|
|
|
|
-uint16_t FileServer::port() const
|
|
|
+uint16_t HttpServer::port() const
|
|
|
{
|
|
|
return m_port;
|
|
|
}
|
|
|
|
|
|
-bool FileServer::isRunning() const
|
|
|
+bool HttpServer::isRunning() const
|
|
|
{
|
|
|
return m_thread.isRunning();
|
|
|
}
|
|
|
|
|
|
-void FileServer::run(const char *addr, unsigned short port)
|
|
|
+void HttpServer::run(const char *addr, unsigned short port)
|
|
|
{
|
|
|
m_addr = std::string(addr);
|
|
|
m_port = port;
|
|
|
@@ -41,14 +41,14 @@ void FileServer::run(const char *addr, unsigned short port)
|
|
|
m_thread.start();
|
|
|
}
|
|
|
|
|
|
-void FileServer::stop()
|
|
|
+void HttpServer::stop()
|
|
|
{
|
|
|
m_server.stop();
|
|
|
m_thread.quit();
|
|
|
m_thread.wait();
|
|
|
}
|
|
|
|
|
|
-void FileServer::run_hhttp_sever()
|
|
|
+void HttpServer::run_hhttp_sever()
|
|
|
{
|
|
|
|
|
|
// 心跳
|