重构Steam网络管理,整合房间管理功能,添加多路复用支持,优化TCP服务器和消息处理
This commit is contained in:
@@ -9,9 +9,7 @@
|
||||
#include <isteamnetworkingsockets.h>
|
||||
#include <isteamnetworkingutils.h>
|
||||
#include <steamnetworkingtypes.h>
|
||||
#include <isteammatchmaking.h>
|
||||
#include "steam_message_handler.h"
|
||||
#include "steam_room_manager.h"
|
||||
|
||||
// Forward declarations
|
||||
class TCPClient;
|
||||
@@ -35,18 +33,6 @@ public:
|
||||
bool initialize();
|
||||
void shutdown();
|
||||
|
||||
// Hosting
|
||||
bool startHosting();
|
||||
void stopHosting();
|
||||
|
||||
// Lobby
|
||||
bool createLobby();
|
||||
void leaveLobby();
|
||||
bool searchLobbies();
|
||||
bool joinLobby(CSteamID lobbyID);
|
||||
const std::vector<CSteamID>& getLobbies() const;
|
||||
CSteamID getCurrentLobby() const;
|
||||
|
||||
// Joining
|
||||
bool joinHost(uint64 hostID);
|
||||
void disconnect();
|
||||
@@ -55,12 +41,21 @@ public:
|
||||
bool isHost() const { return g_isHost; }
|
||||
bool isClient() const { return g_isClient; }
|
||||
bool isConnected() const { return g_isConnected; }
|
||||
const std::vector<std::pair<CSteamID, std::string>>& getFriendsList() const { return friendsList; }
|
||||
const std::map<HSteamNetConnection, UserInfo>& getUserMap() const { return userMap; }
|
||||
const std::vector<HSteamNetConnection>& getConnections() const { return connections; }
|
||||
HSteamNetConnection getConnection() const { return g_hConnection; }
|
||||
ISteamNetworkingSockets* getInterface() const { return m_pInterface; }
|
||||
|
||||
// For SteamRoomManager access
|
||||
std::unique_ptr<TCPServer>*& getServer() { return server_; }
|
||||
int*& getLocalPort() { return localPort_; }
|
||||
boost::asio::io_context*& getIOContext() { return io_context_; }
|
||||
std::map<HSteamNetConnection, std::shared_ptr<TCPClient>>*& getClientMap() { return clientMap_; }
|
||||
std::mutex*& getClientMutex() { return clientMutex_; }
|
||||
HSteamListenSocket& getListenSock() { return hListenSock; }
|
||||
ISteamNetworkingSockets* getInterface() { return m_pInterface; }
|
||||
bool& getIsHost() { return g_isHost; }
|
||||
|
||||
void 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);
|
||||
|
||||
// Message handler
|
||||
@@ -74,9 +69,6 @@ public:
|
||||
void setHostSteamID(CSteamID id) { g_hostSteamID = id; }
|
||||
CSteamID getHostSteamID() const { return g_hostSteamID; }
|
||||
|
||||
friend class SteamFriendsCallbacks;
|
||||
friend class SteamMatchmakingCallbacks;
|
||||
|
||||
private:
|
||||
// Steam API
|
||||
ISteamNetworkingSockets* m_pInterface;
|
||||
@@ -99,12 +91,6 @@ private:
|
||||
const int MAX_RETRIES = 3;
|
||||
int g_currentVirtualPort;
|
||||
|
||||
// Friends
|
||||
std::vector<std::pair<CSteamID, std::string>> friendsList;
|
||||
|
||||
// Room manager
|
||||
SteamRoomManager* roomManager_;
|
||||
|
||||
// Message handler dependencies
|
||||
boost::asio::io_context* io_context_;
|
||||
std::map<HSteamNetConnection, std::shared_ptr<TCPClient>>* clientMap_;
|
||||
|
||||
Reference in New Issue
Block a user