更新Steam网络信息,添加用户信息更新功能以获取延迟和中继状态
This commit is contained in:
@@ -117,7 +117,7 @@ bool SteamNetworkingManager::initialize() {
|
||||
std::cout << "Cleared Rich Presence on startup" << std::endl;
|
||||
|
||||
// Check if callbacks are registered
|
||||
std::cout << "Steam API initialized, callbacks should be registered" << std::endl;
|
||||
std::cout << "Steam API initialized" << std::endl;
|
||||
|
||||
// Get friends list
|
||||
int friendCount = SteamFriends()->GetFriendCount(k_EFriendFlagAll);
|
||||
@@ -224,24 +224,17 @@ bool SteamNetworkingManager::joinHost(uint64 hostID) {
|
||||
}
|
||||
}
|
||||
|
||||
void SteamNetworkingManager::setMessageHandlerDependencies(boost::asio::io_context& io_context, std::map<HSteamNetConnection, std::shared_ptr<TCPClient>>& clientMap, std::mutex& clientMutex, std::unique_ptr<TCPServer>& server, int& localPort) {
|
||||
io_context_ = &io_context;
|
||||
clientMap_ = &clientMap;
|
||||
clientMutex_ = &clientMutex;
|
||||
server_ = &server;
|
||||
localPort_ = &localPort;
|
||||
messageHandler_ = new SteamMessageHandler(io_context, m_pInterface, connections, clientMap, clientMutex, connectionsMutex, server, g_isHost, localPort);
|
||||
}
|
||||
|
||||
void SteamNetworkingManager::startMessageHandler() {
|
||||
if (messageHandler_) {
|
||||
messageHandler_->start();
|
||||
}
|
||||
}
|
||||
|
||||
void SteamNetworkingManager::stopMessageHandler() {
|
||||
if (messageHandler_) {
|
||||
messageHandler_->stop();
|
||||
void SteamNetworkingManager::update() {
|
||||
std::lock_guard<std::mutex> lock(connectionsMutex);
|
||||
for (auto& pair : userMap) {
|
||||
HSteamNetConnection conn = pair.first;
|
||||
UserInfo& userInfo = pair.second;
|
||||
SteamNetConnectionInfo_t info;
|
||||
SteamNetConnectionRealTimeStatus_t status;
|
||||
if (m_pInterface->GetConnectionInfo(conn, &info) && m_pInterface->GetConnectionRealTimeStatus(conn, &status, 0, nullptr)) {
|
||||
userInfo.ping = status.m_nPing;
|
||||
userInfo.isRelay = (info.m_idPOPRelay != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user