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