增加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

@@ -64,11 +64,16 @@ namespace ylib
* param
* callback 触发回调
******************************************************************/
void other(std::function<void(network::http::request*, network::http::response*)> callback);
void other(std::function<void(network::http::request*, network::http::response*,network::http::websocket_message*)> callback);
/******************************************************************
* function数据接收后回调
******************************************************************/
void on_recved(std::function<void(const ylib::buffer& begin, ylib::buffer* end)> callback);
/******************************************************************
* function关闭回调
******************************************************************/
void on_close(std::function<void(uint64 connid,network::http::websocket_message* ws_msg)> callback);
/******************************************************************
* function数据发送前回调
* desc不支持大文件断点传输方式
@@ -90,6 +95,8 @@ namespace ylib
private:
// 添加任务
void push(reqpack* rp);
// 添加连接断开任务
void push_close(uint64 connid,std::shared_ptr<network::http::websocket_message> ws_msg);
// 是否为代理任务
bool is_proxy(reqpack* rp);
// 是否为CDN服务
@@ -102,11 +109,13 @@ namespace ylib
// 线程池
IHPThreadPool* m_threadpool;
// [回调] 未订阅请求
std::function<void(network::http::request*, network::http::response*)> m_callback_other;
std::function<void(network::http::request*, network::http::response*,network::http::websocket_message*)> m_callback_other;
// [回调] 接收后
std::function<void(const ylib::buffer& begin, ylib::buffer* end)> m_callback_recved;
// [回调] 发送前
std::function<void(const ylib::buffer& begin, ylib::buffer* end)> m_callback_sendbefore;
// [回调] 关闭
std::function<void(uint64 connid,network::http::websocket_message* ws_msg)> m_callback_close;
// 拦截器
std::unique_ptr<network::http::interceptor> m_interceptor;
// 订阅器