重构SteamMessageHandler,移除多余线程,改用定时器实现异步轮询,优化消息接收逻辑

This commit is contained in:
Ayndpa
2025-11-19 21:42:51 +08:00
parent 04ce1a4a03
commit e8a326be53
2 changed files with 35 additions and 33 deletions

View File

@@ -22,8 +22,7 @@ public:
std::shared_ptr<MultiplexManager> getMultiplexManager(HSteamNetConnection conn);
private:
void run();
void pollMessages();
void startAsyncPoll();
boost::asio::io_context& io_context_;
ISteamNetworkingSockets* m_pInterface_;
@@ -34,9 +33,9 @@ private:
std::map<HSteamNetConnection, std::shared_ptr<MultiplexManager>> multiplexManagers_;
std::thread thread_;
std::thread io_thread_;
std::unique_ptr<boost::asio::steady_timer> timer_;
bool running_;
int currentPollInterval_; // 当前轮询间隔(毫秒)
};
#endif // STEAM_MESSAGE_HANDLER_H