📄 serversessionfactory.cpp
字号:
#include "stdafx.h"
#include ".\serversessionfactory.h"
#include <Macro.h>
#include "GameDBProxySession.h"
#include "FieldServerSession.h"
#include "MasterServerSession.h"
#include "BattleServerSession.h"
#include "TempServerSession.h"
#include "AgentServerSession.h"
#include "GuildServerSession.h"
ServerSessionFactory::ServerSessionFactory(void)
{
m_pGameDBProxyPool = new CMemoryPoolFactory<GameDBProxySession>;
m_pFieldServerPool = new CMemoryPoolFactory<FieldServerSession>;
m_pMasterServerPool = new CMemoryPoolFactory<MasterServerSession>;
m_pBattleServerPool = new CMemoryPoolFactory<BattleServerSession>;
m_pTempServerPool = new CMemoryPoolFactory<TempServerSession>;
m_pAgentServerPool = new CMemoryPoolFactory<AgentServerSession>;
m_pGuildServerPool = new CMemoryPoolFactory<GuildServerSession>;
m_pGameDBProxyPool->Initialize( 2, 2 );
m_pMasterServerPool->Initialize( 2, 2 );
m_pAgentServerPool->Initialize( 2, 2 );
m_pGuildServerPool->Initialize( 2, 2 );
/// 咯矾俺啊 瞪 荐 乐栏骨肺 俺荐 炼例捞 鞘夸!!!
m_pBattleServerPool->Initialize( 10, 2 );
m_pFieldServerPool->Initialize( 10, 2 );
m_pTempServerPool->Initialize( 10, 10 );
}
ServerSessionFactory::~ServerSessionFactory(void)
{
SAFE_DELETE( m_pGameDBProxyPool );
SAFE_DELETE( m_pFieldServerPool );
SAFE_DELETE( m_pMasterServerPool );
SAFE_DELETE( m_pBattleServerPool );
SAFE_DELETE( m_pTempServerPool );
SAFE_DELETE( m_pAgentServerPool );
SAFE_DELETE( m_pGuildServerPool );
}
ServerSession * ServerSessionFactory::AllocServerSession( eSERVER_TYPE eServerType )
{
ServerSession *pServerSession = NULL;
switch( eServerType )
{
case FIELD_SERVER:
return m_pFieldServerPool->Alloc();
break;
case BATTLE_SERVER:
pServerSession = m_pBattleServerPool->Alloc();
break;
//case MASTER_PROXY:
//pServerSession = m_pGameDBProxyPool->Alloc();
break;
//case CHATTING_SERVER:
//pServerSession = m_pGameDBProxyPool->Alloc();
break;
case MASTER_SERVER:
pServerSession = m_pMasterServerPool->Alloc();
break;
//case AUTH_SERVER:
//pServerSession = m_pGameDBProxyPool->Alloc();
break;
case GAME_DBPROXY:
pServerSession = m_pGameDBProxyPool->Alloc();
break;
case TEMP_SERVER:
pServerSession = m_pTempServerPool->Alloc();
break;
case AGENT_SERVER:
pServerSession = m_pAgentServerPool->Alloc();
break;
case GUILD_SERVER:
pServerSession = m_pGuildServerPool->Alloc();
break;
}
if( pServerSession ) pServerSession->Init();
return pServerSession;
}
VOID ServerSessionFactory::FreeServerSession( ServerSession * pServerSession )
{
pServerSession->Release();
switch( pServerSession->GetServerType() )
{
case FIELD_SERVER:
return m_pFieldServerPool->Free( (FieldServerSession *)pServerSession );
case BATTLE_SERVER:
return m_pBattleServerPool->Free( (BattleServerSession *)pServerSession );
case MASTER_SERVER:
return m_pMasterServerPool->Free( (MasterServerSession *)pServerSession );
case GAME_DBPROXY:
return m_pGameDBProxyPool->Free( (GameDBProxySession*)pServerSession );
case TEMP_SERVER:
return m_pTempServerPool->Free( (TempServerSession *)pServerSession );
case AGENT_SERVER:
return m_pAgentServerPool->Free( (AgentServerSession *)pServerSession );
case GUILD_SERVER:
return m_pGuildServerPool->Free( (GuildServerSession *)pServerSession );
default:
{
ASSERT( !"肋给等 鸥涝狼 辑滚技记阑 Free且 荐 绝促" );
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -