mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
linker errors
This commit is contained in:
56
dWeb/Web.h
Normal file
56
dWeb/Web.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef __WEB_H__
|
||||
#define __WEB_H__
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include "mongoose.h"
|
||||
#include "json_fwd.hpp"
|
||||
#include "eHTTPStatusCode.h"
|
||||
|
||||
|
||||
|
||||
enum class eHTTPMethod;
|
||||
|
||||
typedef struct mg_mgr mg_mgr;
|
||||
|
||||
struct HTTPReply {
|
||||
eHTTPStatusCode status = eHTTPStatusCode::NOT_FOUND;
|
||||
std::string message = "{\"error\":\"Not Found\"}";
|
||||
};
|
||||
|
||||
struct HTTPRoute {
|
||||
std::string path;
|
||||
eHTTPMethod method;
|
||||
std::function<void(HTTPReply&, const std::string&)> handle;
|
||||
};
|
||||
|
||||
struct WSAction {
|
||||
std::string action;
|
||||
std::function<void(mg_connection*, nlohmann::json)> handle;
|
||||
};
|
||||
|
||||
struct WSMessage {
|
||||
uint32_t id;
|
||||
std::string sub;
|
||||
std::string message;
|
||||
};
|
||||
|
||||
class Web {
|
||||
public:
|
||||
Web();
|
||||
~Web();
|
||||
void ReceiveRequests();
|
||||
void static SendWSMessage(std::string sub, const std::string& message);
|
||||
bool Startup(const std::string& listen_ip, const uint32_t listen_port);
|
||||
void RegisterHTTPRoute(HTTPRoute route);
|
||||
void RegisterWSAction(WSAction action);
|
||||
private:
|
||||
mg_mgr mgr;
|
||||
};
|
||||
|
||||
namespace Game {
|
||||
Web web;
|
||||
}
|
||||
|
||||
#endif // !__WEB_H__
|
Reference in New Issue
Block a user