initial commit

This commit is contained in:
2025-08-05 15:53:44 +08:00
commit 09dc02ae52
553 changed files with 137665 additions and 0 deletions

30
third_party/libhv/docs/cn/WebSocketServer.md vendored Executable file
View File

@@ -0,0 +1,30 @@
WebSocket 服务端类
```c++
// WebSocketServer 继承自 HttpServer
class WebSocketServer : public HttpServer {
// 注册WebSocket业务类
void registerWebSocketService(WebSocketService* service);
};
// WebSocket业务类
struct WebSocketService {
// 打开回调
std::function<void(const WebSocketChannelPtr&, const HttpRequestPtr&)> onopen;
// 消息回调
std::function<void(const WebSocketChannelPtr&, const std::string&)> onmessage;
// 关闭回调
std::function<void(const WebSocketChannelPtr&)> onclose;
// 心跳间隔
int ping_interval;
};
```
测试代码见 [examples/websocket_server_test.cpp](../../examples/websocket_server_test.cpp)