//============================================================================================================================= /// SolarAuthServer Main Entry /** @author Lee Eun-pa @since 2006. 08. 11 @remark - SolarAuthServer @note @history - */ //============================================================================================================================= #include "stdafx.h" #include #include #include #include #include #include #include #include #include //============================================================ // #include "SolarAuthServer.h" #include "Sessions/ServerSession.h" #include "Sessions/ServerSessionManager.h" // //============================================================ // MACROs //#define __DEBUG_CHECK_ALLOCCHECK //============================================================ // Module Varialbes static SolarAuthServer* s_pSolarAuthServer = NULL; // <ÃʱâÈ­ Çϴµ¥ »ç¿ëµÇ´Â ÇÔ¼ö ÁýÇÕµé -Àӽà ¸ðÀ½-> #include "Entry.SubFunc.cxx" // //============================================================ // // <ÇÁ·Î±×·¥ ½ÃÀÛÁ¡> // int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { SolarDump sSolarDump; StartMemoryLeakCheck(); //BreakPointOnMemoryLeak(3228); //BreakPointOnMemoryLeak(2509); #if defined(_DEBUG) && defined(__DEBUG_CHECK_ALLOCCHECK) InitAllocCheck();//Memory Leak Check Start #endif if( !InitRuntimeEnvionment() ) return 0; DISPMSG( \ "=============================================================================" \ " SolarAuthServer Initialization Start!\n" \ "=============================================================================\n"); // ¼­¹ö ÃʱâÈ­ s_pSolarAuthServer = new SolarAuthServer(); if( !s_pSolarAuthServer->DoInit( "./SolarAuthServer.ini", SolarAuthServer::CreateServerSideAcceptedObject, SolarAuthServer::DestroyServerSideAcceptedObject, SolarAuthServer::DestroyServerSideConnectedObject, NULL, NULL, NULL ) ) { DISPMSG( "[WinMain] Server Initialization Failed!\n" ); system( "pause" ); return 0; } SUNLOG( eFULL_LOG, "=============================================================================" \ " SUN Online SolarAuth Server Initialization Complete.\n" \ "=============================================================================\n" ); // // switch( s_pSolarAuthServer->GetServiceMode() ) { case eCONSOLE_MODE: { s_pSolarAuthServer->DoProcess(); s_pSolarAuthServer->DoRelease(); // ServerFrameÀ» »ó¼ÓÇϸ鼭 »ý±ä¹®Á¦ ÇØ°á ¸ñÀû // ReleaseÀÌÈÄÀÇ »õ·Î¿î Instance ¸¦ »ý¼ºÇÏ´Â °ÍµéÀº µû·Î ¿©±â¼­ ÇØÁ¦Çϱâ·Î ÇÑ´Ù. s_pSolarAuthServer->Finalize(); SAFE_DELETE(s_pSolarAuthServer); // ¼­¹ö Á¾·á DISPMSG( "[WinMain] Server is terminated...\n" ); g_SimpleConsole.Release(); } break; case eSERVICE_MODE: { DISPMSG( "[WinMain] <<<<< Service Mode >>>>>\n" ); //__START_SERVICE( SolarAuthServiceApp ); } break; } #if defined(_DEBUG) && defined(__DEBUG_CHECK_ALLOCCHECK) DeInitAllocCheck();//Memory Leak Check End #endif return 0; } SolarAuthServer* SolarAuthServer::GetMainFrame() { return s_pSolarAuthServer; } ServerSession* SolarAuthServer::Handler_AllocServerSession( eSERVER_TYPE serverType ) { ServerSession* pServerSession = (ServerSession*)Handler_AllocServerSession_NoInit( serverType ); if( pServerSession ) { pServerSession->Init( s_pSolarAuthServer ); } return pServerSession; } VOID SolarAuthServer::Handler_FreeServerSession( ServerSession* pServerSession ) { if( pServerSession ) { pServerSession->Release(); Handler_FreeServerSession_NoRelease( pServerSession ); } } NetworkObject* SolarAuthServer::Handler_AllocServerSession_NoInit( eSERVER_TYPE serverType ) { NetworkObject* pSession = NULL; if( TEMP_SERVER == serverType ) pSession = (NetworkObject*)s_pSolarAuthServer->m_TempServerPool.Alloc(); else if( MASTER_SERVER == serverType ) pSession = (NetworkObject*)s_pSolarAuthServer->m_MasterServerPool.Alloc(); else if( ACCOUNT_DBPROXY == serverType ) pSession = (NetworkObject*)s_pSolarAuthServer->m_ADBPServerPool.Alloc(); else { SUNLOG( eFULL_LOG, "[ServerSessionFactory::AllocServerSession] À߸øµÈ ¼­¹ö ŸÀÔÀÌ´Ù. Ç®¿¡¼­ ÇÒ´çÇÒ ¼ö ¾ø½À´Ï´Ù." ); } return pSession; } VOID SolarAuthServer::Handler_FreeServerSession_NoRelease( NetworkObject* pNetworkObject ) { if( !pNetworkObject ) { SUNLOG( eCRITICAL_LOG, "NULL·Î ServerSession ÇØÁ¦ÇÏ·Á°í ÇÑ´Ù." ); return; } ServerSession* pServerSession = (ServerSessionEx*)pNetworkObject; eSERVER_TYPE serverType = pServerSession->GetServerType(); if( TEMP_SERVER == serverType ) s_pSolarAuthServer->m_TempServerPool.Free( static_cast(pServerSession) ); else if( MASTER_SERVER == serverType ) s_pSolarAuthServer->m_MasterServerPool.Free( static_cast(pServerSession) ); else if( ACCOUNT_DBPROXY == serverType ) s_pSolarAuthServer->m_ADBPServerPool.Free( static_cast(pServerSession) ); else { SUNLOG( eFULL_LOG, "[ServerSessionFactory::FreeServerSession] À߸øµÈ ŸÀÔÀÇ ¼­¹ö¼¼¼ÇÀ» FreeÇÒ ¼ö ¾ø´Ù" ); } } ///------------------------------------------------------------------------------------------------ /// ¼­¹öÂÊ Äݹé NetworkObject* SolarAuthServer::CreateServerSideAcceptedObject() { SERVER_SESSION_DELEGATOR pServerSession = (ServerSessionEx*)SolarAuthServer::Handler_AllocServerSession_NoInit( TEMP_SERVER ); ((ServerSession*)pServerSession())->Init( s_pSolarAuthServer ); return (NetworkObject*)pServerSession(); } VOID SolarAuthServer::DestroyServerSideAcceptedObject( NetworkObject* pNetworkObject ) { SolarAuthServer::Handler_FreeServerSession_NoRelease( pNetworkObject ); } VOID SolarAuthServer::DestroyServerSideConnectedObject( NetworkObject* pNetworkObject ) { __UNUSED(pNetworkObject); } //int _tmain(int argc, _TCHAR* argv[]) //{ // return 0; //} // // SolarAuthServiceApp Implementation // //#ifdef _DEBUG //__DECLARE_SERVICE( SolarAuthServiceApp, "AgentServer_d" ); //#else //__DECLARE_SERVICE( SolarAuthServiceApp, "AgentServer" ); //#endif DWORD SolarAuthServiceApp::OnInit ( DWORD argc, LPTSTR* argv, DWORD* specificError ) { __UNUSED(argc); __UNUSED(argv); __UNUSED(specificError); return 0; } VOID SolarAuthServiceApp::Update() { s_pSolarAuthServer->DoProcess(); s_pSolarAuthServer->DoRelease(); SAFE_DELETE( s_pSolarAuthServer ); g_SimpleConsole.Release(); } VOID SolarAuthServiceApp::OnStop() { //s_pSolarAuthServer->Shutdown(); } VOID SolarAuthServiceApp::OnShutDown() { printf("SHUT DOWN"); }