From 7e16d488554b9360903f6b928b2c9f61d1fb19da Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Mon, 4 Mar 2013 21:09:01 +0000 Subject: Removed the unused cHeartbeat object git-svn-id: http://mc-server.googlecode.com/svn/trunk@1251 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- VC2008/MCServer.vcproj | 8 --- source/HeartBeat.cpp | 143 ------------------------------------------------- source/HeartBeat.h | 28 ---------- 3 files changed, 179 deletions(-) delete mode 100644 source/HeartBeat.cpp delete mode 100644 source/HeartBeat.h diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index 8dc8afc00..e4c0e7490 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -440,14 +440,6 @@ RelativePath="..\source\GroupManager.h" > - - - - diff --git a/source/HeartBeat.cpp b/source/HeartBeat.cpp deleted file mode 100644 index 45acd0e1f..000000000 --- a/source/HeartBeat.cpp +++ /dev/null @@ -1,143 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "HeartBeat.h" -#include "MCLogger.h" -#include "md5/md5.h" - -#include "Root.h" -#include "Server.h" - - - - - -cHeartBeat::cHeartBeat() -{ - m_State = 0; - Authenticate(); -} - - - - - -cHeartBeat::~cHeartBeat() -{ -} - - - - - -void cHeartBeat::ReceivedData( char a_Data[256], int a_Size ) -{ - if( a_Size < 0 ) // Disconnected - return; - - char MySalt[] = "1234567890"; - - if( a_Size == 0 ) - { - Authenticate(); - return; - } - - bool bLoop = false; - do - { - switch (m_State) - { - case 1: - { - m_ServerID = std::string( a_Data, a_Size ); - LOGINFO("Got server ID %s", m_ServerID.c_str() ); - std::string Hash = md5( m_ServerID + std::string( MySalt ) ); - CloseSocket(); - if( Connect( "mc-server.org", 80 ) ) - { - SendMessage( (std::string("GET http://master.mc-server.org/?hash=") + Hash + std::string("&server=") + m_ServerID + "\n").c_str() ); - m_State = 2; - } - } - break; - case 2: - { - std::string ReturnedString = std::string( a_Data, a_Size ); - if( ReturnedString.compare("VALIDATED") == 0 ) - { - LOGINFO("Successfully validated server on master server list"); - } - else - { - LOGINFO("Could not validate server! Will try again later."); - cSleep::MilliSleep( 10*1000 ); - Authenticate(); - return; - } - m_State = 3; - } // Don't break, but fall through and update server info - case 3: - { - cSleep::MilliSleep( 10*1000 ); - SendUpdate(); - m_State = 4; - } - break; - case 4: - { - if( a_Data[0] == '0' ) - { - LOGINFO("Successfully updated server info!"); - cSleep::MilliSleep( 10*1000 ); - SendUpdate(); - } - else - { - LOGINFO("Failed to update server info, reauthenticating"); - Authenticate(); - } - } - default: - break; - }; - } while( bLoop ); -} - - - - - -void cHeartBeat::SendUpdate() -{ - CloseSocket(); - if( Connect( "mc-server.org", 80 ) ) - { - int Port = cRoot::Get()->GetServer()->GetPort(); - AString Msg; - AString sPort; - Printf(sPort, "%i", Port); - AString sChecksum = md5( m_ServerID + sPort ); - Printf(Msg, "GET http://master.mc-server.org/?update=%s&checksum=%s&port=%d\n", m_ServerID.c_str(), sChecksum.c_str(), Port); - SendMessage(Msg.c_str()); - } -} - - - - - -void cHeartBeat::Authenticate() -{ - CloseSocket(); - if (Connect( "mc-server.org", 80)) - { - m_State = 1; - int RetVal = SendMessage( "GET http://master.mc-server.org/\r\n\r\n"); - LOGINFO("Returned %i", RetVal); - } -} - - - - diff --git a/source/HeartBeat.h b/source/HeartBeat.h deleted file mode 100644 index 79465507c..000000000 --- a/source/HeartBeat.h +++ /dev/null @@ -1,28 +0,0 @@ - -#pragma once - -#include "OSSupport/TCPLink.h" - - - - - -class cHeartBeat : public cTCPLink -{ -public: - cHeartBeat(); - ~cHeartBeat(); -private: - virtual void ReceivedData( char a_Data[256], int a_Size ); - - void Authenticate(); - int m_State; - - void SendUpdate(); - - std::string m_ServerID; -}; - - - - -- cgit v1.2.3