Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit 41af585

Browse files
committed
更新文档
1 parent 77cafa0 commit 41af585

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88

99
## 项目依赖
1010

11-
> 本项目所有依赖都为 Header-Only 库,已经内置到本项目的 third-party 文件夹中。
11+
> 本项目所有依赖都为 Header-Only 库,已经内置到本项目的 mirai-third-party 文件夹中。
1212
13-
1. [**cpp-httplib**](https://github.com/yhirose/cpp-httplib) A C++ header-only HTTP/HTTPS server and client library.
13+
1. [**yhirose/cpp-httplib**](https://github.com/yhirose/cpp-httplib) A C++ header-only HTTP/HTTPS server and client library.
1414

15-
2. [**nlohmann/json**](https://github.com/nlohmann/json) 解析 JSON 数据。
15+
2. [**nlohmann/json**](https://github.com/nlohmann/json) JSON for Modern C++.
1616

17-
3. [**ThreadPool**](https://github.com/cyanray/CURLWrapper) 线程池库,用于异步处理消息。
17+
3. [**progschj/ThreadPool**](https://github.com/progschj/ThreadPool) A simple C++11 Thread Pool implementation.
18+
19+
4. [**dhbaird/EasyWSClient**](https://github.com/dhbaird/easywsclient) A short and sweet WebSocket client for C++.
1820

1921
## 项目文档
2022

doc/使用说明.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ bot.On<NewFriendRequestEvent>([&](NewFriendRequestEvent e)
115115
bot.EventLoop();
116116
```
117117

118+
mirai-cpp 默认使用 WebSocket 拉取事件和消息,如果需要通过 HTTP 来拉取消息,可以调用 UseHTTP 函数。(不需要开启 mirai-api-http 的全局 WebSocket 设置,mirai-cpp 会自动针对 Session 开启 WebSocket。)
119+
120+
```C++
121+
bot.UseHTTP().EventLoop();
122+
```
123+
124+
推荐使用 WebSocket, 使用 WebSocket 比 HTTP 效率更高。
125+
118126
bot.EventLoop() 方法会阻塞当前线程,内含死循环不断轮询新的事件。该方法不会抛出异常,如果有错误默认会在 cerr 输出。
119127

120128
如果希望自定义 EventLoop 处理错误信息的方式,可以尝试这样写:

0 commit comments

Comments
 (0)