增加websocket支持

This commit is contained in:
Dev User
2026-08-04 20:06:33 +08:00
parent 0ffb86d5a0
commit c7a9e1c457
13 changed files with 517 additions and 59 deletions

View File

@@ -20,6 +20,9 @@ namespace ylib
public:
response(network::http::reqpack* reqpack);
~response();
bool send_header(ushort stateNum, const std::string& stateDesc = "OK");
/// <summary>发送 WebSocket 帧。opcode 默认 0x1 文本0x2二进制 0x8关闭 0xA pong</summary>
bool send_ws(const char* buf, size_t buf_len, int opcode = 0x1);
bool send(const char* buf, size_t buf_len, ushort stateNum = 200, const std::string& stateDesc = "OK");
bool send(const ylib::buffer& value, ushort stateNum = 200, const std::string& stateDesc = "OK");
bool send(const std::string& value, ushort stateNum = 200, const std::string& stateDesc = "OK");
@@ -28,7 +31,10 @@ namespace ylib
std::map<std::string, std::string>* headers();
bool redirect(const std::string& filepath, bool MovedPermanently = false);
bool forward(const std::string& filepath);
public:
void response_done(){m_response = true;}
bool is_response_done(){return m_response;}
public:
ylib::json sjson;
private:
bool filecache(const uint64& last_modify_time);