Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
264 lines
6.3 KiB
C++
264 lines
6.3 KiB
C++
// MonitoringTool.cpp : Defines the class behaviors for the application.
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "MonitoringTool.h"
|
|
#include "MonitoringToolSetup.h"
|
|
#include "GlobalFunc.h"
|
|
#include "ChatServerEventhandler.h"
|
|
#include "ChattingPage.h"
|
|
|
|
#include <Network/ClientNetwork/ClientEventHandler.h>
|
|
#include <Stream/Buffer/BufferFactory.h>
|
|
#include <Stream/Buffer/Buffer.h>
|
|
#include <Log/ServerLog.h>
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
|
|
// CMonitoringToolApp
|
|
|
|
BEGIN_MESSAGE_MAP(CMonitoringToolApp, CWinApp)
|
|
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// CMonitoringToolApp construction
|
|
|
|
CMonitoringToolApp::CMonitoringToolApp()
|
|
: m_DefaultiniFileName(_T("./RylMonitoringToolSetup.ini"))
|
|
, m_bIsAuthorized(false)
|
|
, m_lpEventHandlerMgr(0)
|
|
, m_lpManageServerEventHandler(0)
|
|
, m_lpBufferFactory(0)
|
|
{
|
|
// TODO: add construction code here,
|
|
// Place all significant initialization in InitInstance
|
|
}
|
|
|
|
|
|
// The one and only CMonitoringToolApp object
|
|
|
|
CMonitoringToolApp theApp;
|
|
|
|
|
|
// CMonitoringToolApp initialization
|
|
|
|
BOOL CMonitoringToolApp::InitInstance()
|
|
{
|
|
m_lpEventHandlerMgr = new ClientNet::CClientEventHandlerMgr;
|
|
if(!m_lpEventHandlerMgr) { return FALSE; }
|
|
|
|
m_lpBufferFactory = new CPoolBufferFactory;
|
|
if(!m_lpBufferFactory) { return FALSE; }
|
|
|
|
InitCommonControls();
|
|
|
|
CWinApp::InitInstance();
|
|
|
|
AfxEnableControlContainer();
|
|
|
|
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
|
|
|
|
InitServerNameMap();
|
|
InitServerIndexMap();
|
|
|
|
CMonitoringToolDlg dlg;
|
|
m_pMainWnd = &dlg;
|
|
|
|
INT_PTR nResponse = dlg.DoModal();
|
|
|
|
if (nResponse == IDOK) { }
|
|
else if (nResponse == IDCANCEL) { }
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
int CMonitoringToolApp::ExitInstance()
|
|
{
|
|
delete m_lpEventHandlerMgr;
|
|
m_lpEventHandlerMgr = 0;
|
|
|
|
delete m_lpBufferFactory;
|
|
m_lpBufferFactory = 0;
|
|
|
|
return CWinApp::ExitInstance();
|
|
}
|
|
|
|
/// \brief 서버그룹명 맵 초기화
|
|
void CMonitoringToolApp::InitServerNameMap()
|
|
{
|
|
m_ServerNameMap.clear();
|
|
|
|
CMonitoringToolSetup Setup = CMonitoringToolSetup::GetInstance();
|
|
|
|
const int MAX_BUFFER = 256;
|
|
const char* szSection = _T("SERVER_GROUP_INFO");
|
|
|
|
char szKey[MAX_BUFFER];
|
|
unsigned int nServerGroup;
|
|
|
|
for(unsigned int nIndex = 0; nIndex < Setup.GetInt(szSection, _T("SERVER_GROUP_NUM")); ++nIndex)
|
|
{
|
|
_snprintf(szKey, MAX_BUFFER, _T("SERVER_GROUP_INDEX_%02d"), nIndex);
|
|
nServerGroup = Setup.GetInt(szSection, szKey, 0xFFFFFFFF);
|
|
|
|
if(nServerGroup != 0xFFFFFFFF)
|
|
{
|
|
_snprintf(szKey, MAX_BUFFER, _T("SERVER_GROUP_NAME_%02d"), nIndex);
|
|
m_ServerNameMap.insert(ServerNameMap::value_type(nServerGroup, Setup.GetString(szSection, szKey)));
|
|
}
|
|
}
|
|
}
|
|
|
|
/// \brief 서버그룹명 얻기
|
|
/// \param nServerGroup 서버그룹 인덱스
|
|
/// \return 서버그룹명
|
|
const char* CMonitoringToolApp::GetServerName(unsigned int nServerGroup)
|
|
{
|
|
ServerNameMap::iterator find = m_ServerNameMap.find(nServerGroup);
|
|
|
|
if(find != m_ServerNameMap.end())
|
|
{
|
|
return find->second.c_str();
|
|
}
|
|
|
|
return _T("Tool");
|
|
}
|
|
|
|
/// \brief 서버그룹 인덱스 맵 초기화
|
|
void CMonitoringToolApp::InitServerIndexMap()
|
|
{
|
|
m_ServerIndexMap.clear();
|
|
|
|
CMonitoringToolSetup Setup = CMonitoringToolSetup::GetInstance();
|
|
|
|
const int MAX_BUFFER = 256;
|
|
const char* szSection = _T("SERVER_GROUP_INFO");
|
|
|
|
char szKey[MAX_BUFFER];
|
|
unsigned int nServerGroup;
|
|
|
|
for(unsigned int nIndex = 0; nIndex < Setup.GetInt(szSection, _T("SERVER_GROUP_NUM")); ++nIndex)
|
|
{
|
|
_snprintf(szKey, MAX_BUFFER, _T("SERVER_GROUP_INDEX_%02d"), nIndex);
|
|
nServerGroup = Setup.GetInt(szSection, szKey, 0xFFFFFFFF);
|
|
|
|
if(nServerGroup != 0xFFFFFFFF)
|
|
{
|
|
_snprintf(szKey, MAX_BUFFER, _T("SERVER_GROUP_NAME_%02d"), nIndex);
|
|
m_ServerIndexMap.insert(ServerIndexMap::value_type(Setup.GetString(szSection, szKey), nServerGroup));
|
|
}
|
|
}
|
|
}
|
|
|
|
/// \brief 서버그룹 인덱스 얻기
|
|
/// \param strServerName 서버그룹명
|
|
/// \return 서버 그룹 인덱스
|
|
unsigned int CMonitoringToolApp::GetServerIndex(CString strServerName)
|
|
{
|
|
ServerIndexMap::iterator find = m_ServerIndexMap.find(strServerName);
|
|
|
|
if(find != m_ServerIndexMap.end())
|
|
{
|
|
return find->second;
|
|
}
|
|
|
|
return 100;
|
|
}
|
|
|
|
void CMonitoringToolApp::RegisterManagerHandler(ClientNet::CManagerServerEventHandler* lpHandler)
|
|
{
|
|
m_lpManageServerEventHandler = lpHandler;
|
|
|
|
|
|
}
|
|
|
|
void CMonitoringToolApp::RemoveManagerHandler(ClientNet::CManagerServerEventHandler* lpHandler)
|
|
{
|
|
if(m_lpManageServerEventHandler == lpHandler)
|
|
{
|
|
m_lpManageServerEventHandler = 0;
|
|
}
|
|
}
|
|
|
|
/// \brief 채팅서버 연결 세션 등록
|
|
/// \param nServerGroup 채팅서버의 그룹 인덱스
|
|
/// \param lpHandler 채팅서버 연결 세션 포인터
|
|
void CMonitoringToolApp::RegisterChatHandler(unsigned int nServerGroup,
|
|
ClientNet::CChatServerEventHandler* lpHandler)
|
|
{
|
|
ChatServerHandlerMap::iterator pos = m_ChatHandlerMap.find(nServerGroup);
|
|
ChatServerHandlerMap::iterator end = m_ChatHandlerMap.end();
|
|
|
|
if (pos != end && lpHandler != pos->second)
|
|
{
|
|
// 이미 존재한다.
|
|
pos->second = lpHandler;
|
|
}
|
|
else
|
|
{
|
|
m_ChatHandlerMap.insert(ChatServerHandlerMap::value_type(nServerGroup, lpHandler));
|
|
}
|
|
}
|
|
|
|
void CMonitoringToolApp::RemoveChatHandler(unsigned int nServerGroup,
|
|
ClientNet::CChatServerEventHandler* lpHandler)
|
|
{
|
|
ChatServerHandlerMap::iterator pos = m_ChatHandlerMap.find(nServerGroup);
|
|
ChatServerHandlerMap::iterator end = m_ChatHandlerMap.end();
|
|
|
|
if (pos != end)
|
|
{
|
|
m_ChatHandlerMap.erase(pos);
|
|
}
|
|
}
|
|
|
|
ClientNet::CChatServerEventHandler* CMonitoringToolApp::GetChatServerHandler(unsigned int nServerGroup)
|
|
{
|
|
ChatServerHandlerMap::iterator pos = m_ChatHandlerMap.find(nServerGroup);
|
|
|
|
if (pos != m_ChatHandlerMap.end())
|
|
{
|
|
return pos->second;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
bool CMonitoringToolApp::RegisterWindow(unsigned int nIDD, CWnd* lpWindow)
|
|
{
|
|
return m_WindowMap.insert(WindowMap::value_type(nIDD, lpWindow)).second;
|
|
}
|
|
|
|
bool CMonitoringToolApp::RemoveWindow(unsigned int nIDD)
|
|
{
|
|
return 0 != m_WindowMap.erase(nIDD);
|
|
}
|
|
|
|
CWnd* CMonitoringToolApp::GetRegisteredWindow(unsigned int nIDD)
|
|
{
|
|
WindowMap::iterator find = m_WindowMap.find(nIDD);
|
|
|
|
if(find != m_WindowMap.end())
|
|
{
|
|
return find->second;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/// \brief 결과창에 메세지 출력
|
|
/// \param szResult 출력할 메세지
|
|
void CMonitoringToolApp::ReportResult(const char* szResult)
|
|
{
|
|
CMonitoringToolDlg* lpDlg =
|
|
static_cast<CMonitoringToolDlg*>(theApp.GetRegisteredWindow(IDD_MONITORINGTOOLDLG));
|
|
|
|
if (NULL != lpDlg)
|
|
{
|
|
lpDlg->ReportWorkResult(szResult);
|
|
}
|
|
} |