Files
UNSWebServerCore_WindowsDLL/UNSWebServerCore/ServerCore.h
T
2026-06-30 17:46:34 +08:00

48 lines
1.4 KiB
C++

/*
* Unknown Network Service Web Server Core
* Version 1.2.2
*
* TCP Core - boost::aiso
* HTTP Core - webcc
* Application Level Repack & Windows Service Interface - UnknownObject
*/
#pragma once
#include <thread>
#include <memory>
#include "Global.h"
#include "Export.h"
#include "FileReceiver.h"
#include "ServerProcessor.h"
#include "SyncFileReceiver.h"
class UNSWSC_DLL_EXPORT ServerCore
{
private:
class Impl;
std::unique_ptr<Impl> pimpl;
public:
ServerCore(int port);
~ServerCore();
ServerCore() = delete;
ServerCore(const ServerCore& obj) = delete;
ServerCore& operator=(const ServerCore& obj) = delete;
public:
void Run(int worker_thread = 1, int loop_thread = 1);
void ThreadRun(int worker_thread = 1, int loop_thread = 1);
void Stop();
bool Running();
void UpdateProcessor();
bool EnableCORSSupport();
bool AppenedProcessor(std::string url, ServerProcessorPtr ptr, std::uint32_t methods, bool enable_ip_check = false);
bool AppenedFileReceiver(std::string url, FileReceiverPtr ptr, std::uint32_t methods, FileProcessorCallback fpcb, bool html_response = false);
bool AppenedFileReceiver(std::string url, SyncFileReceiverPtr ptr, std::uint32_t methods, bool html_response = false);
public:
//启用WebCC日志
//path: 日志存放文件夹,留空为仅控制台日志
//level: 0-4, 0=VERB, 1=INFO, 2=USER(default), 3=WARN, 4=ERROR
static void EnableWebCCLog(const std::string& path = "", int level = 2);
};