Refactor Steam Networking Components
- Removed SteamMessageHandler class and its implementation files. - Integrated control packet handling directly into the SteamMessageHandler. - Updated TCPClient and TCPServer classes to improve connection management and error handling. - Added SteamNetworkingManager class to manage Steam networking, including lobby creation and connection handling. - Implemented callbacks for Steam Friends and Matchmaking to handle lobby events. - Enhanced message forwarding logic between TCP clients and Steam connections. - Introduced control packet handling for ping responses. - Improved thread safety with mutexes for shared resources.
This commit is contained in:
42
steamnet/steam_message_handler.h
Normal file
42
steamnet/steam_message_handler.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef STEAM_MESSAGE_HANDLER_H
|
||||
#define STEAM_MESSAGE_HANDLER_H
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <memory>
|
||||
#include <boost/asio.hpp>
|
||||
#include <steamnetworkingtypes.h>
|
||||
#include "tcp_server.h"
|
||||
#include "tcp/tcp_client.h"
|
||||
#include "control_packets.h"
|
||||
|
||||
class SteamMessageHandler {
|
||||
public:
|
||||
SteamMessageHandler(boost::asio::io_context& io_context, ISteamNetworkingSockets* interface, std::vector<HSteamNetConnection>& connections, std::map<HSteamNetConnection, std::shared_ptr<TCPClient>>& clientMap, std::mutex& clientMutex, std::mutex& connectionsMutex, std::unique_ptr<TCPServer>& server, bool& g_isHost, int& localPort);
|
||||
~SteamMessageHandler();
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
private:
|
||||
void run();
|
||||
void pollMessages();
|
||||
void handleControlPacket(const char* data, size_t size, HSteamNetConnection conn);
|
||||
|
||||
boost::asio::io_context& io_context_;
|
||||
ISteamNetworkingSockets* m_pInterface_;
|
||||
std::vector<HSteamNetConnection>& connections_;
|
||||
std::map<HSteamNetConnection, std::shared_ptr<TCPClient>>& clientMap_;
|
||||
std::mutex& clientMutex_;
|
||||
std::mutex& connectionsMutex_;
|
||||
std::unique_ptr<TCPServer>& server_;
|
||||
bool& g_isHost_;
|
||||
int& localPort_;
|
||||
|
||||
std::thread thread_;
|
||||
bool running_;
|
||||
};
|
||||
|
||||
#endif // STEAM_MESSAGE_HANDLER_H
|
||||
Reference in New Issue
Block a user