* cleanup/remove all networking callbacks on object destruction

* reset pointers on client destruction
This commit is contained in:
otavepto 2024-03-23 17:01:27 +02:00 committed by otavepto
parent b6c7df40b6
commit 3c9b327fb5
20 changed files with 93 additions and 72 deletions

View File

@ -41,11 +41,17 @@ Auth_Manager::Auth_Manager(class Settings *settings, class Networking *network,
this->network->setCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &steam_auth_manager_ticket_callback, this); this->network->setCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &steam_auth_manager_ticket_callback, this);
} }
Auth_Manager::~Auth_Manager()
{
this->network->rmCallback(CALLBACK_ID_AUTH_TICKET, settings->get_local_steam_id(), &steam_auth_manager_ticket_callback, this);
this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &steam_auth_manager_ticket_callback, this);
}
#define STEAM_TICKET_PROCESS_TIME 0.03 #define STEAM_TICKET_PROCESS_TIME 0.03
void Auth_Manager::launch_callback(CSteamID id, EAuthSessionResponse resp, double delay) void Auth_Manager::launch_callback(CSteamID id, EAuthSessionResponse resp, double delay)
{ {
ValidateAuthTicketResponse_t data; ValidateAuthTicketResponse_t data{};
data.m_SteamID = id; data.m_SteamID = id;
data.m_eAuthSessionResponse = resp; data.m_eAuthSessionResponse = resp;
data.m_OwnerSteamID = id; data.m_OwnerSteamID = id;
@ -55,11 +61,11 @@ void Auth_Manager::launch_callback(CSteamID id, EAuthSessionResponse resp, doubl
void Auth_Manager::launch_callback_gs(CSteamID id, bool approved) void Auth_Manager::launch_callback_gs(CSteamID id, bool approved)
{ {
if (approved) { if (approved) {
GSClientApprove_t data; GSClientApprove_t data{};
data.m_SteamID = data.m_OwnerSteamID = id; data.m_SteamID = data.m_OwnerSteamID = id;
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
} else { } else {
GSClientDeny_t data; GSClientDeny_t data{};
data.m_SteamID = id; data.m_SteamID = id;
data.m_eDenyReason = k_EDenyNotLoggedOn; //TODO: other reasons? data.m_eDenyReason = k_EDenyNotLoggedOn; //TODO: other reasons?
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));

View File

@ -643,6 +643,7 @@ class Auth_Manager {
std::vector<struct Auth_Data> outbound; std::vector<struct Auth_Data> outbound;
public: public:
Auth_Manager(class Settings *settings, class Networking *network, class SteamCallBacks *callbacks); Auth_Manager(class Settings *settings, class Networking *network, class SteamCallBacks *callbacks);
~Auth_Manager();
void Callback(Common_Message *msg); void Callback(Common_Message *msg);
uint32 getTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket ); uint32 getTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket );

View File

@ -238,7 +238,9 @@ Steam_Friends(Settings* settings, Networking* network, SteamCallResults* callbac
~Steam_Friends() ~Steam_Friends()
{ {
//TODO rm network callbacks this->network->rmCallback(CALLBACK_ID_FRIEND, settings->get_local_steam_id(), &Steam_Friends::steam_friends_callback, this);
this->network->rmCallback(CALLBACK_ID_FRIEND_MESSAGES, settings->get_local_steam_id(), &Steam_Friends::steam_friends_callback, this);
this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Friends::steam_friends_callback, this);
this->run_every_runcb->remove(&Steam_Friends::steam_friends_run_every_runcb, this); this->run_every_runcb->remove(&Steam_Friends::steam_friends_run_every_runcb, this);
} }

View File

@ -69,7 +69,7 @@ Steam_Game_Coordinator(class Settings *settings, class Networking *network, clas
~Steam_Game_Coordinator() ~Steam_Game_Coordinator()
{ {
//TODO rm network callbacks //this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Game_Coordinator::steam_callback, this);
this->run_every_runcb->remove(&Steam_Game_Coordinator::steam_run_every_runcb, this); this->run_every_runcb->remove(&Steam_Game_Coordinator::steam_run_every_runcb, this);
} }

View File

@ -59,7 +59,7 @@ Steam_Game_Search(class Settings *settings, class Networking *network, class Ste
~Steam_Game_Search() ~Steam_Game_Search()
{ {
//TODO rm network callbacks //this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Game_Search::steam_callback, this);
this->run_every_runcb->remove(&Steam_Game_Search::steam_run_every_runcb, this); this->run_every_runcb->remove(&Steam_Game_Search::steam_run_every_runcb, this);
} }

View File

@ -57,7 +57,7 @@ Steam_Masterserver_Updater(class Settings *settings, class Networking *network,
~Steam_Masterserver_Updater() ~Steam_Masterserver_Updater()
{ {
//TODO rm network callbacks this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Masterserver_Updater::steam_callback, this);
this->run_every_runcb->remove(&Steam_Masterserver_Updater::steam_run_every_runcb, this); this->run_every_runcb->remove(&Steam_Masterserver_Updater::steam_run_every_runcb, this);
} }

View File

@ -325,7 +325,8 @@ Steam_Matchmaking(class Settings *settings, class Networking *network, class Ste
~Steam_Matchmaking() ~Steam_Matchmaking()
{ {
//TODO rm network callbacks this->network->rmCallback(CALLBACK_ID_LOBBY, settings->get_local_steam_id(), &Steam_Matchmaking::steam_matchmaking_callback, this);
this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Matchmaking::steam_matchmaking_callback, this);
this->run_every_runcb->remove(&Steam_Matchmaking::steam_matchmaking_run_every_runcb, this); this->run_every_runcb->remove(&Steam_Matchmaking::steam_matchmaking_run_every_runcb, this);
} }

View File

@ -69,6 +69,8 @@ public ISteamMatchmakingServers001
void RequestOldServerList(AppId_t iApp, ISteamMatchmakingServerListResponse001 *pRequestServersResponse, EMatchMakingType type); void RequestOldServerList(AppId_t iApp, ISteamMatchmakingServerListResponse001 *pRequestServersResponse, EMatchMakingType type);
public: public:
Steam_Matchmaking_Servers(class Settings *settings, class Networking *network); Steam_Matchmaking_Servers(class Settings *settings, class Networking *network);
~Steam_Matchmaking_Servers();
// Request a new list of servers of a particular type. These calls each correspond to one of the EMatchMakingType values. // Request a new list of servers of a particular type. These calls each correspond to one of the EMatchMakingType values.
// Each call allocates a new asynchronous request object. // Each call allocates a new asynchronous request object.
// Request object must be released by calling ReleaseRequest( hServerListRequest ) // Request object must be released by calling ReleaseRequest( hServerListRequest )

View File

@ -251,7 +251,8 @@ Steam_Networking(class Settings *settings, class Networking *network, class Stea
~Steam_Networking() ~Steam_Networking()
{ {
//TODO rm network callbacks this->network->rmCallback(CALLBACK_ID_NETWORKING, settings->get_local_steam_id(), &Steam_Networking::steam_networking_callback, this);
this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Networking::steam_networking_callback, this);
this->run_every_runcb->remove(&Steam_Networking::steam_networking_run_every_runcp, this); this->run_every_runcb->remove(&Steam_Networking::steam_networking_run_every_runcp, this);
} }

View File

@ -82,7 +82,8 @@ Steam_Networking_Messages(class Settings *settings, class Networking *network, c
~Steam_Networking_Messages() ~Steam_Networking_Messages()
{ {
//TODO rm network callbacks this->network->rmCallback(CALLBACK_ID_NETWORKING_MESSAGES, settings->get_local_steam_id(), &Steam_Networking_Messages::steam_callback, this);
this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Networking_Messages::steam_callback, this);
this->run_every_runcb->remove(&Steam_Networking_Messages::steam_run_every_runcb, this); this->run_every_runcb->remove(&Steam_Networking_Messages::steam_run_every_runcb, this);
} }

View File

@ -133,7 +133,8 @@ Steam_Networking_Sockets(class Settings *settings, class Networking *network, cl
~Steam_Networking_Sockets() ~Steam_Networking_Sockets()
{ {
//TODO rm network callbacks this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Networking_Sockets::steam_callback, this);
this->network->rmCallback(CALLBACK_ID_NETWORKING_SOCKETS, settings->get_local_steam_id(), &Steam_Networking_Sockets::steam_callback, this);
this->run_every_runcb->remove(&Steam_Networking_Sockets::steam_run_every_runcb, this); this->run_every_runcb->remove(&Steam_Networking_Sockets::steam_run_every_runcb, this);
if (this->s->used) { if (this->s->used) {
this->s->used -= 1; this->s->used -= 1;

View File

@ -60,7 +60,7 @@ Steam_Networking_Sockets_Serialized(class Settings *settings, class Networking *
~Steam_Networking_Sockets_Serialized() ~Steam_Networking_Sockets_Serialized()
{ {
//TODO rm network callbacks this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Networking_Sockets_Serialized::steam_callback, this);
this->run_every_runcb->remove(&Steam_Networking_Sockets_Serialized::steam_run_every_runcb, this); this->run_every_runcb->remove(&Steam_Networking_Sockets_Serialized::steam_run_every_runcb, this);
} }

View File

@ -64,7 +64,7 @@ Steam_Networking_Utils(class Settings *settings, class Networking *network, clas
~Steam_Networking_Utils() ~Steam_Networking_Utils()
{ {
//TODO rm network callbacks //this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Networking_Utils::steam_callback, this);
this->run_every_runcb->remove(&Steam_Networking_Utils::steam_run_every_runcb, this); this->run_every_runcb->remove(&Steam_Networking_Utils::steam_run_every_runcb, this);
} }

View File

@ -59,7 +59,7 @@ Steam_Parties(class Settings *settings, class Networking *network, class SteamCa
~Steam_Parties() ~Steam_Parties()
{ {
//TODO rm network callbacks //this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Parties::steam_callback, this);
this->run_every_runcb->remove(&Steam_Parties::steam_run_every_runcb, this); this->run_every_runcb->remove(&Steam_Parties::steam_run_every_runcb, this);
} }

View File

@ -58,7 +58,7 @@ Steam_RemotePlay(class Settings *settings, class Networking *network, class Stea
~Steam_RemotePlay() ~Steam_RemotePlay()
{ {
//TODO rm network callbacks //this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_RemotePlay::steam_callback, this);
this->run_every_runcb->remove(&Steam_RemotePlay::steam_run_every_runcb, this); this->run_every_runcb->remove(&Steam_RemotePlay::steam_run_every_runcb, this);
} }

View File

@ -59,7 +59,7 @@ Steam_TV(class Settings *settings, class Networking *network, class SteamCallRes
~Steam_TV() ~Steam_TV()
{ {
//TODO rm network callbacks //this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_TV::steam_callback, this);
//this->run_every_runcb->remove(&Steam_TV::steam_run_every_runcb, this); //this->run_every_runcb->remove(&Steam_TV::steam_run_every_runcb, this);
} }

View File

@ -48,8 +48,8 @@ Steam_Unified_Messages(class Settings *settings, class Networking *network, clas
this->settings = settings; this->settings = settings;
this->network = network; this->network = network;
this->run_every_runcb = run_every_runcb; this->run_every_runcb = run_every_runcb;
// this->network->setCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Unified_Messages::steam_callback, this); // this->network->setCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Unified_Messages::steam_callback, this);
// this->run_every_runcb->add(&Steam_Unified_Messages::steam_run_every_runcb, this); // this->run_every_runcb->add(&Steam_Unified_Messages::steam_run_every_runcb, this);
this->callback_results = callback_results; this->callback_results = callback_results;
this->callbacks = callbacks; this->callbacks = callbacks;
@ -57,8 +57,8 @@ Steam_Unified_Messages(class Settings *settings, class Networking *network, clas
~Steam_Unified_Messages() ~Steam_Unified_Messages()
{ {
//TODO rm network callbacks // this->network->rmCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &Steam_Unified_Messages::steam_callback, this);
// this->run_every_runcb->remove(&Steam_Unified_Messages::steam_run_every_runcb, this); // this->run_every_runcb->remove(&Steam_Unified_Messages::steam_run_every_runcb, this);
} }
// Sends a service method (in binary serialized form) using the Steam Client. // Sends a service method (in binary serialized form) using the Steam Client.

View File

@ -133,61 +133,61 @@ Steam_Client::Steam_Client()
Steam_Client::~Steam_Client() Steam_Client::~Steam_Client()
{ {
delete steam_gameserver; delete steam_gameserver; steam_gameserver = nullptr;
delete steam_gameserver_utils; delete steam_gameserver_utils; steam_gameserver_utils = nullptr;
delete steam_gameserverstats; delete steam_gameserverstats; steam_gameserverstats = nullptr;
delete steam_gameserver_networking; delete steam_gameserver_networking; steam_gameserver_networking = nullptr;
delete steam_gameserver_http; delete steam_gameserver_http; steam_gameserver_http = nullptr;
delete steam_gameserver_inventory; delete steam_gameserver_inventory; steam_gameserver_inventory = nullptr;
delete steam_gameserver_ugc; delete steam_gameserver_ugc; steam_gameserver_ugc = nullptr;
delete steam_gameserver_apps; delete steam_gameserver_apps; steam_gameserver_apps = nullptr;
delete steam_gameserver_networking_sockets; delete steam_gameserver_networking_sockets; steam_gameserver_networking_sockets = nullptr;
delete steam_gameserver_networking_sockets_serialized; delete steam_gameserver_networking_sockets_serialized; steam_gameserver_networking_sockets_serialized = nullptr;
delete steam_gameserver_networking_messages; delete steam_gameserver_networking_messages; steam_gameserver_networking_messages = nullptr;
delete steam_gameserver_game_coordinator; delete steam_gameserver_game_coordinator; steam_gameserver_game_coordinator = nullptr;
delete steam_masterserver_updater; delete steam_masterserver_updater; steam_masterserver_updater = nullptr;
delete steam_matchmaking; delete steam_matchmaking; steam_matchmaking = nullptr;
delete steam_matchmaking_servers; delete steam_matchmaking_servers; steam_matchmaking_servers = nullptr;
delete steam_user_stats; delete steam_user_stats; steam_user_stats = nullptr;
delete steam_apps; delete steam_apps; steam_apps = nullptr;
delete steam_networking; delete steam_networking; steam_networking = nullptr;
delete steam_remote_storage; delete steam_remote_storage; steam_remote_storage = nullptr;
delete steam_screenshots; delete steam_screenshots; steam_screenshots = nullptr;
delete steam_http; delete steam_http; steam_http = nullptr;
delete steam_controller; delete steam_controller; steam_controller = nullptr;
delete steam_ugc; delete steam_ugc; steam_ugc = nullptr;
delete steam_applist; delete steam_applist; steam_applist = nullptr;
delete steam_music; delete steam_music; steam_music = nullptr;
delete steam_musicremote; delete steam_musicremote; steam_musicremote = nullptr;
delete steam_HTMLsurface; delete steam_HTMLsurface; steam_HTMLsurface = nullptr;
delete steam_inventory; delete steam_inventory; steam_inventory = nullptr;
delete steam_video; delete steam_video; steam_video = nullptr;
delete steam_parental; delete steam_parental; steam_parental = nullptr;
delete steam_networking_sockets; delete steam_networking_sockets; steam_networking_sockets = nullptr;
delete steam_networking_sockets_serialized; delete steam_networking_sockets_serialized; steam_networking_sockets_serialized = nullptr;
delete steam_networking_messages; delete steam_networking_messages; steam_networking_messages = nullptr;
delete steam_game_coordinator; delete steam_game_coordinator; steam_game_coordinator = nullptr;
delete steam_networking_utils; delete steam_networking_utils; steam_networking_utils = nullptr;
delete steam_unified_messages; delete steam_unified_messages; steam_unified_messages = nullptr;
delete steam_game_search; delete steam_game_search; steam_game_search = nullptr;
delete steam_parties; delete steam_parties; steam_parties = nullptr;
delete steam_remoteplay; delete steam_remoteplay; steam_remoteplay = nullptr;
delete steam_tv; delete steam_tv; steam_tv = nullptr;
delete steam_utils; delete steam_utils; steam_utils = nullptr;
delete steam_friends; delete steam_friends; steam_friends = nullptr;
delete steam_user; delete steam_user; steam_user = nullptr;
delete steam_overlay; delete steam_overlay; steam_overlay = nullptr;
delete ugc_bridge; delete ugc_bridge; ugc_bridge = nullptr;
delete run_every_runcb; delete run_every_runcb; run_every_runcb = nullptr;
delete callbacks_server; delete callbacks_server; callbacks_server = nullptr;
delete callbacks_client; delete callbacks_client; callbacks_client = nullptr;
delete callback_results_server; delete callback_results_server; callback_results_server = nullptr;
delete callback_results_client; delete callback_results_client; callback_results_client = nullptr;
delete network; delete network; network = nullptr;
} }
void Steam_Client::userLogIn() void Steam_Client::userLogIn()

View File

@ -33,6 +33,11 @@ Steam_Matchmaking_Servers::Steam_Matchmaking_Servers(class Settings *settings, c
this->network->setCallback(CALLBACK_ID_GAMESERVER, (uint64) 0, &network_callback, this); this->network->setCallback(CALLBACK_ID_GAMESERVER, (uint64) 0, &network_callback, this);
} }
Steam_Matchmaking_Servers::~Steam_Matchmaking_Servers()
{
this->network->rmCallback(CALLBACK_ID_GAMESERVER, (uint64) 0, &network_callback, this);
}
static int server_list_request = 0; static int server_list_request = 0;
HServerListRequest Steam_Matchmaking_Servers::RequestServerList(AppId_t iApp, ISteamMatchmakingServerListResponse *pRequestServersResponse, EMatchMakingType type) HServerListRequest Steam_Matchmaking_Servers::RequestServerList(AppId_t iApp, ISteamMatchmakingServerListResponse *pRequestServersResponse, EMatchMakingType type)

View File

@ -141,14 +141,15 @@ Steam_Overlay::Steam_Overlay(Settings* settings, SteamCallResults* callback_resu
++i; ++i;
} }
run_every_runcb->add(&Steam_Overlay::overlay_run_callback, this);
this->network->setCallback(CALLBACK_ID_STEAM_MESSAGES, settings->get_local_steam_id(), &Steam_Overlay::overlay_networking_callback, this); this->network->setCallback(CALLBACK_ID_STEAM_MESSAGES, settings->get_local_steam_id(), &Steam_Overlay::overlay_networking_callback, this);
run_every_runcb->add(&Steam_Overlay::overlay_run_callback, this);
} }
Steam_Overlay::~Steam_Overlay() Steam_Overlay::~Steam_Overlay()
{ {
if (settings->disable_overlay) return; if (settings->disable_overlay) return;
this->network->rmCallback(CALLBACK_ID_STEAM_MESSAGES, settings->get_local_steam_id(), &Steam_Overlay::overlay_networking_callback, this);
run_every_runcb->remove(&Steam_Overlay::overlay_run_callback, this); run_every_runcb->remove(&Steam_Overlay::overlay_run_callback, this);
} }