130 lines
3.4 KiB
C++
130 lines
3.4 KiB
C++
#include "StdAfx.h"
|
|
#include ".\handler_sma.h"
|
|
#include <PacketStruct_SMA.h>
|
|
#include <PacketStruct_SM.h>
|
|
#include "User.h"
|
|
#include "UserManager.h"
|
|
#include "UnitServer.h"
|
|
#include "WorldManager.h"
|
|
|
|
Handler_SMA::Handler_SMA(void)
|
|
{
|
|
}
|
|
|
|
Handler_SMA::~Handler_SMA(void)
|
|
{
|
|
}
|
|
|
|
VOID Handler_SMA::OnHandler_MO_RTTG_SERVERSHUTDOWN_ANS( ServerSession* pSession, MSG_BASE* pMsg, int nSize )
|
|
{
|
|
MSG_MO_RTTG_SERVERSHUTDOWN_ANS *pRecvMsg = (MSG_MO_RTTG_SERVERSHUTDOWN_ANS*)pMsg;
|
|
|
|
MSG_SM_SERVER_SHUTDOWN_ACK AckMsg;
|
|
|
|
// 서버종료 성공
|
|
if( pRecvMsg->dwError == 0 )
|
|
{
|
|
MSGOUT( "Server Shutdown Success! World[%u] Channel[%u] ServerType[%u] ServerIndex[%u] \n",
|
|
pRecvMsg->m_ServerKey.GetWorldID(),
|
|
pRecvMsg->m_ServerKey.GetChannelID(),
|
|
pRecvMsg->m_ServerKey.GetServerType(),
|
|
pRecvMsg->m_ServerKey.GetServerID() );
|
|
AckMsg.m_byResult = RC_SERVER_SHUTDOWN_SUCCESS;
|
|
}
|
|
// 서버종료 실패
|
|
else
|
|
{
|
|
MSGOUT( "Server Shutdown Error! World[%u] Channel[%u] ServerType[%u] ServerIndex[%u] \n",
|
|
pRecvMsg->m_ServerKey.GetWorldID(),
|
|
pRecvMsg->m_ServerKey.GetChannelID(),
|
|
pRecvMsg->m_ServerKey.GetServerType(),
|
|
pRecvMsg->m_ServerKey.GetServerID() );
|
|
AckMsg.m_byResult = RC_SERVER_SHUTDOWN_FAIL;
|
|
}
|
|
|
|
// 패치를 실행시킨 유저를 찾는다.
|
|
User *pUser = (User*)UserManager::Instance()->GetUser( pRecvMsg->dwKey );
|
|
if( !pUser )
|
|
{
|
|
MSGOUT( "[MO_RTTG_SERVERSHUTDOWN_ANS] Can't find ServerStart-User! \n" );
|
|
return;
|
|
}
|
|
|
|
// 서버종료 결과를 알린다.
|
|
AckMsg.m_ServerInfo.m_byWorld = pRecvMsg->m_ServerKey.GetWorldID();
|
|
AckMsg.m_ServerInfo.m_byChannel = pRecvMsg->m_ServerKey.GetChannelID();
|
|
AckMsg.m_ServerInfo.m_byServerType = pRecvMsg->m_ServerKey.GetServerType();
|
|
AckMsg.m_ServerInfo.m_byServerNum = pRecvMsg->m_ServerKey.GetServerID();
|
|
pUser->SendPacket( &AckMsg, sizeof(AckMsg) );
|
|
}
|
|
|
|
VOID Handler_SMA::OnHandler_MO_RTTG_ALL_SERVER_STATUS_NTF( ServerSession* pSession, MSG_BASE* pMsg, int nSize )
|
|
{
|
|
MSG_MO_RTTG_ALL_SERVER_STATUS_NTF *pRecvMsg = (MSG_MO_RTTG_ALL_SERVER_STATUS_NTF*)pMsg;
|
|
|
|
if( pRecvMsg->m_Count > MSG_MO_RTTG_ALL_SERVER_STATUS_NTF::MAX_SERVER_COUNT ) return;
|
|
|
|
MSG_SM_SERVER_INFO_CHANGE_CMD MgrMsg;
|
|
MgrMsg.m_Count = 0;
|
|
|
|
for( int i = 0; i < pRecvMsg->m_Count; i++ )
|
|
{
|
|
#ifdef __20080310__CHANGE_SET_SERVERKEY
|
|
SERVER_KEY key( pRecvMsg->m_ServerConnectInfo[i].m_ServerKey);
|
|
#endif
|
|
UnitServer *pUnitServer = WorldManager::Instance()->FindUnitServer( key );
|
|
|
|
if( !pUnitServer )
|
|
{
|
|
MSGOUT( "[MO_RTTG_ALL_SERVER_STATUS_NTF] Can't Find UnitServer[%d %d %d %d] \n",
|
|
pRecvMsg->m_ServerConnectInfo[i].m_ServerKey.GetWorldID(), pRecvMsg->m_ServerConnectInfo[i].m_ServerKey.GetChannelID(),
|
|
pRecvMsg->m_ServerConnectInfo[i].m_ServerKey.GetServerType(), pRecvMsg->m_ServerConnectInfo[i].m_ServerKey.GetServerID() );
|
|
continue;
|
|
}
|
|
|
|
// 해당서버의 ON/OFF 정보를 갱신한다.
|
|
pUnitServer->GetServerInfo().SetServerStatus( (eSERVER_STATUS)pRecvMsg->m_ServerConnectInfo[i].m_bConnected );
|
|
|
|
// UpdateManager에 알려줄 서버정보를 셋팅한다.
|
|
pUnitServer->GetServerInfo().SerializeStream( MgrMsg.m_ServerInfoEx[MgrMsg.m_Count], FALSE );
|
|
|
|
MSGOUT( "[MO_RTTG_ALL_SERVER_STATUS_NTF] ServerKey[%d] Connected[%d]\n", MgrMsg.m_ServerInfoEx[MgrMsg.m_Count].m_dwServerKey, MgrMsg.m_ServerInfoEx[MgrMsg.m_Count].m_byStatus );
|
|
|
|
MgrMsg.m_Count++;
|
|
}
|
|
|
|
// 서버에 접속되어 있는 모든 User(Manager)에 서버상태 변경을 알린다.
|
|
if( MgrMsg.m_Count )
|
|
UserManager::Instance()->SendPacketAll( &MgrMsg, MgrMsg.GetSize() );
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|