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

Commit 1a35259

Browse files
committed
降低 CPU 使用;
1 parent 08f5c61 commit 1a35259

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/mirai_bot.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,15 +752,17 @@ namespace Cyan
752752
while (ws->getReadyState() != WebSocket::CLOSED && this->ws_enabled_)
753753
{
754754

755-
ws->poll();
755+
ws->poll(20);
756756
ws->dispatch([&](const std::string& message)
757757
{
758-
eventJsonStr = std::move(message);
758+
eventJsonStr = message;
759759
});
760+
// 这部分不能在lambda表示中,否则异常无法被EventLoop捕捉
760761
if (!eventJsonStr.empty())
761762
{
762763
json j = json::parse(eventJsonStr);
763764
ProcessEvents(j);
765+
eventJsonStr.resize(0);
764766
}
765767
}
766768
}

0 commit comments

Comments
 (0)