#include "StdAfx.h" #include ".\serversessionmanager.h" #include #include "ServerSession.h" #ifdef _NA_006543_20130318_HEARTBEAT #include "AgentServerSession.h" #endif ServerSessionManager::ServerSessionManager(void) { } ServerSessionManager::~ServerSessionManager(void) { } VOID ServerSessionManager::AddSession( ServerSession* pSession ) { m_mapSession.insert( std::make_pair( pSession->GetSessionIndex(), pSession ) ); } //¸Þ¸ð¸®»óÀÇ ÇØÁ¦´Â ÆÑÅ丮¿¡¼­ ÇÑ´Ù. ¿©±â¼­´Â ¿ä¼ÒÀÇ »èÁ¦¸¸ ÇÑ´Ù. VOID ServerSessionManager::DelSession( DWORD dwSessionIndex ) { SERVER_SESSION_MAP_ITER iter = m_mapSession.find( dwSessionIndex ); if( iter != m_mapSession.end() ) //Á¸Àç m_mapSession.erase( iter ); } ServerSession* ServerSessionManager::Find( DWORD dwSessionIndex ) { SERVER_SESSION_MAP_ITER iter = m_mapSession.find( dwSessionIndex ); if( iter != m_mapSession.end() ) //Á¸Àç { ServerSession* pSession = iter->second; if( pSession ) return pSession; } return NULL; } ServerSession* ServerSessionManager::FindAgentSession( DWORD dwAgentKey ) { SERVER_SESSION_MAP_ITER iter; for( iter = m_mapSession.begin(); iter != m_mapSession.end(); ++iter ) { ServerSession* pSession = iter->second; if( pSession ) { if( pSession->GetServerKey() == dwAgentKey ) return pSession; } } return NULL; } VOID ServerSessionManager::Release() { m_mapSession.clear(); } ServerSession* ServerSessionManager::FindMasterSession() { SERVER_SESSION_MAP_ITER iter; for( iter = m_mapSession.begin(); iter != m_mapSession.end(); ++iter ) { ServerSession* pSession = iter->second; if( pSession ) { if( pSession->GetServerType() == UPDATE_MASTER ) return pSession; } } return NULL; } #ifdef _NA_006543_20130318_HEARTBEAT VOID ServerSessionManager::update( ) { SERVER_SESSION_MAP_ITER iter = m_mapSession.begin(); for (; iter != m_mapSession.end(); ++iter) { ServerSession* const session = iter->second; if (session && session->GetServerType() == UPDATE_AGENT ) static_cast(session)->update(); } } #endif