From c2b42171415da954f1fb1ae5c690b0d2d7b2af85 Mon Sep 17 00:00:00 2001 From: KyleSanderson Date: Wed, 8 Jan 2014 03:06:06 -0700 Subject: [PATCH] Add Steam Connection state callbacks. Steam_SteamServersConnected Steam_SteamServersConnectFailure Steam_SteamServersDisconnected --- swforwards.cpp | 44 +++++++++++++++++++++++++++++++++++++++++++- swforwards.h | 10 ++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/swforwards.cpp b/swforwards.cpp index d2b749f..3d73ec1 100644 --- a/swforwards.cpp +++ b/swforwards.cpp @@ -21,14 +21,23 @@ SteamWorksForwards::SteamWorksForwards() : m_CallbackGSClientApprove(this, &SteamWorksForwards::OnGSClientApprove), - m_CallbackValidateTicket(this, &SteamWorksForwards::OnValidateTicket) + m_CallbackValidateTicket(this, &SteamWorksForwards::OnValidateTicket), + m_CallbackSteamConnected(this, &SteamWorksForwards::OnSteamServersConnected), + m_CallbackSteamConnectFailure(this, &SteamWorksForwards::OnSteamServersConnectFailure), + m_CallbackSteamDisconnected(this, &SteamWorksForwards::OnSteamServersDisconnected) { this->pFOVC = forwards->CreateForward("SW_OnValidateClient", ET_Ignore, 2, NULL, Param_Cell, Param_Cell); + this->pFOSSC = forwards->CreateForward("Steam_SteamServersConnected", ET_Ignore, 0, NULL); + this->pFOSSCF = forwards->CreateForward("Steam_SteamServersConnectFailure", ET_Ignore, 1, NULL, Param_Cell); + this->pFOSSD = forwards->CreateForward("Steam_SteamServersDisconnected", ET_Ignore, 1, NULL, Param_Cell); } SteamWorksForwards::~SteamWorksForwards() { forwards->ReleaseForward(this->pFOVC); + forwards->ReleaseForward(this->pFOSSC); + forwards->ReleaseForward(this->pFOSSCF); + forwards->ReleaseForward(this->pFOSSD); } void SteamWorksForwards::NotifyPawnValidateClient(Account_t parent, Account_t child) @@ -52,3 +61,36 @@ void SteamWorksForwards::OnValidateTicket(ValidateAuthTicketResponse_t *pTicket) { this->NotifyPawnValidateClient(pTicket->m_OwnerSteamID.GetAccountID(), pTicket->m_SteamID.GetAccountID()); } + +void SteamWorksForwards::OnSteamServersConnected(SteamServersConnected_t *pResponse) +{ + if (this->pFOSSC->GetFunctionCount() == 0) + { + return; + } + + this->pFOSSC->Execute(NULL); +} + +void SteamWorksForwards::OnSteamServersConnectFailure(SteamServerConnectFailure_t *pResponse) +{ + if (this->pFOSSCF->GetFunctionCount() == 0) + { + return; + } + + this->pFOSSCF->PushCell(pResponse->m_eResult); + this->pFOSSCF->Execute(NULL); +} + +void SteamWorksForwards::OnSteamServersDisconnected(SteamServersDisconnected_t *pResponse) +{ + if (this->pFOSSD->GetFunctionCount() == 0) + { + return; + } + + this->pFOSSD->PushCell(pResponse->m_eResult); + this->pFOSSD->Execute(NULL); +} + diff --git a/swforwards.h b/swforwards.h index 5093b76..06124ea 100644 --- a/swforwards.h +++ b/swforwards.h @@ -35,8 +35,14 @@ class SteamWorksForwards private: STEAM_GAMESERVER_CALLBACK(SteamWorksForwards, OnGSClientApprove, GSClientApprove_t, m_CallbackGSClientApprove); - STEAM_GAMESERVER_CALLBACK(SteamWorksForwards, OnValidateTicket, ValidateAuthTicketResponse_t , m_CallbackValidateTicket); + STEAM_GAMESERVER_CALLBACK(SteamWorksForwards, OnValidateTicket, ValidateAuthTicketResponse_t, m_CallbackValidateTicket); + STEAM_GAMESERVER_CALLBACK(SteamWorksForwards, OnSteamServersConnected, SteamServersConnected_t, m_CallbackSteamConnected); + STEAM_GAMESERVER_CALLBACK(SteamWorksForwards, OnSteamServersConnectFailure, SteamServerConnectFailure_t, m_CallbackSteamConnectFailure); + STEAM_GAMESERVER_CALLBACK(SteamWorksForwards, OnSteamServersDisconnected, SteamServersDisconnected_t, m_CallbackSteamDisconnected); private: - IForward *pFOVC; + IForward *pFOVC; /* Forward On Validate Client */ + IForward *pFOSSC; /* Forward On Steam Servers Connected */ + IForward *pFOSSCF; /* Forward On Steam Servers Connect Failure */ + IForward *pFOSSD; /* Forward On Steam Servers Disconnected */ };