#ifndef __SERVER_SESSION_MANAGER_H__ #define __SERVER_SESSION_MANAGER_H__ #pragma once #include #include class ServerSessionEx; class BattleServerSession; typedef util::SolarHashTable SESSION_LIST; typedef util::SolarHashTable::iterator SESSION_ITERATOR; class ServerSessionManager : public util::Singleton { public: ServerSessionManager(); ~ServerSessionManager(); VOID AddServer( ServerSessionEx* pServer ); VOID RemoveServer( ServerSessionEx* pServer ); ServerSessionEx* FindServer( DWORD dwSessionIndex ); //Low Overhead First // ³·Àº ¿À¹öÇØµå¸¦ °¡Áø ¹èƲ¼­¹ö ¿ì¼±¼øÀ§ DWORD Incr_LOF_BattleServer(); //< ÃÖÀûÀÇ ¹èƲ°¡Á® ¿À°í ´Ù½Ã ÃÖÀû ¹èƲ °è»ê VOID Decr_LOF_BattleServer( DWORD dwSessionIndex ); //< ¹æ°¨¼Ò½Ã۰í ÃÖÀû ¹èƲ °è»ê VOID Process(); ServerSessionEx* GetFieldServer() { return m_pFieldServer; } inline SESSION_ITERATOR Begin() { return m_pSessionHashTable->begin(); } inline SESSION_ITERATOR End() { return m_pSessionHashTable->end(); } DWORD GetBattleServerSessionNum(); SESSION_LIST* GetSessionList() { return m_pSessionHashTable; } ////////////////////////////////////////////////////////////////////////// // template inline VOID Foreach( ObjectOperator& op ) { SESSION_ITERATOR it = m_pSessionHashTable->begin(), end = m_pSessionHashTable->end(); for( ; it != end ; ++it ) { ServerSessionEx* pSession = *it; op( pSession ); } } // ÀڷᱸÁ¶°¡ ¹Ù²î¸é Àû¿ëÇÏÀÚ. //template //inline VOID Foreach( _FN _funcRaw, const _ObjType& _Left ) //{ // std::for_each( m_UserHashTable.begin(), m_UserHashTable.end(), std::bind1st(mem_fun(_funcRaw), _Left) ); //} VOID DisconnectAllServer(); private: BOOL update_LOF_BattleServer(); ServerSessionEx* GetFieldServerSession(); private: ServerSessionEx* m_pFieldServer; BattleServerSession* m_pLOFBattleServer; enum { _MAX_SESSION_BUCKET_SIZE = 10 }; util::SolarHashTable * m_pSessionHashTable; }; #endif // __SERVER_SESSION_MANAGER_H__