Files
Client/Server/ManageTool/MonitoringTool/MonitoringToolDlg.cpp
LGram16 dd97ddec92 Restructure repository to include all source folders
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>
2025-11-29 20:17:20 +09:00

291 lines
8.2 KiB
C++

// MonitoringToolDlg.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "MonitoringTool.h"
#include "MonitoringToolDlg.h"
#include "LoginDlg.h"
#include "MonitoringSheet.h"
#include "ChatServerEventHandler.h"
#include "ManagerServerEventHandler.h"
#include "GlobalFunc.h"
#include "MonitoringToolLog.h"
#include <Network/ClientNetwork/SessionMgr.h>
#include <mmsystem.h>
#include ".\monitoringtooldlg.h"
static UINT_PTR IID_PROCESS_SOCKET = 1;
static UINT_PTR IID_USERSTAT_CHECK = 2; ///< 동시 접속 유저수 정보 갱신 메세지ID
static UINT_PTR IID_CONNECTION_CHECK = 3; ///< 채팅서버와 관리서버 연결상태 갱신 메세지ID
static UINT_PTR IID_PING_CHECK = 4; ///< 핑 체크 메세지ID
const int MAXIMUM_PING_WAIT_TIME = 1000 * 60 * 2; ///< 최대 핑 체크 주기(2분이상 핑 패킷을 받지 못하면 강제 접속 종료)
class CProcessChaServerHandlerPing
{
public:
CProcessChaServerHandlerPing(unsigned long dwCurrentTime)
: m_dwCurrentTime(dwCurrentTime)
{
}
void operator() (unsigned int nServerID, ClientNet::CChatServerEventHandler* lpHandler)
{
if (MAXIMUM_PING_WAIT_TIME < m_dwCurrentTime - lpHandler->GetLastPingRecvTime())
{
theApp.GetEventHandlerMgr().Close(lpHandler);
}
}
private:
unsigned long m_dwCurrentTime;
};
void CALLBACK Process(HWND hWnd, UINT nMsg, UINT_PTR nTimerID, DWORD dwTime)
{
if(IID_PROCESS_SOCKET == nTimerID)
{
theApp.GetEventHandlerMgr().HandleEvents(1000);
}
else if(IID_CONNECTION_CHECK == nTimerID)
{
CChattingPage* lpChattingPage =
static_cast<CChattingPage*>(theApp.GetRegisteredWindow(IDD_CHATTINGPAGE));
if(NULL != lpChattingPage)
{
// 채팅서버 연결 상태 표시
SetConnectionListBox(lpChattingPage->m_ctrlConnectionList);
// 관리서버 연결 상태 표시
lpChattingPage->SetManagerServerConnection();
}
}
else if(IID_PING_CHECK == nTimerID)
{
// 일정 시간동안 Ping이 오지 않으면 접속을 해제한다.
unsigned long dwCurrentTime = timeGetTime();
ClientNet::CManagerServerEventHandler* lpManageServerEventHandler = theApp.GetManagerHandler();
if (0 != lpManageServerEventHandler &&
MAXIMUM_PING_WAIT_TIME < dwCurrentTime - lpManageServerEventHandler->GetLastPingRecvTime())
{
theApp.GetEventHandlerMgr().Close(lpManageServerEventHandler);
}
theApp.EnumChatServerHandler(CProcessChaServerHandlerPing(dwCurrentTime));
}
else if(IID_USERSTAT_CHECK == nTimerID)
{
CChattingPage* lpChattingPage =
static_cast<CChattingPage*>(theApp.GetRegisteredWindow(IDD_CHATTINGPAGE));
if(NULL != lpChattingPage)
{
lpChattingPage->SetUserStat();
CMonitoringToolLog::GetInstance().WriteUserStatLog();
}
}
}
// CMonitoringToolDlg 대화 상자입니다.
IMPLEMENT_DYNAMIC(CMonitoringToolDlg, CDialog)
CMonitoringToolDlg::CMonitoringToolDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMonitoringToolDlg::IDD, pParent)
{
theApp.RegisterWindow(IDD_MONITORINGTOOLDLG, static_cast<CWnd*>(this));
}
CMonitoringToolDlg::~CMonitoringToolDlg()
{
if(NULL != m_pMonitoringSheet)
{
delete m_pMonitoringSheet;
}
if(NULL != m_pFilterUser)
{
delete m_pFilterUser;
}
if(NULL != m_pGMReport)
{
delete m_pGMReport;
}
theApp.RemoveWindow(IDD_MONITORINGTOOLDLG);
}
void CMonitoringToolDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_REPORT_LIST, m_ctrlReportList);
}
BEGIN_MESSAGE_MAP(CMonitoringToolDlg, CDialog)
ON_BN_CLICKED(IDC_AUTH_BTN, OnBnClickedAuthBtn)
ON_MESSAGE(WM_SHOW_MSGBOX, OnShowMessageBox)
ON_WM_SIZE()
ON_WM_SIZING()
ON_BN_CLICKED(IDC_FILTER_BTN, OnBnClickedFilterBtn)
ON_BN_CLICKED(IDC_REPORT_BTN, OnBnClickedReportBtn)
END_MESSAGE_MAP()
// CMonitoringToolDlg 메시지 처리기입니다.
BOOL CMonitoringToolDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetTimer(IID_PROCESS_SOCKET, 200, Process);
SetTimer(IID_USERSTAT_CHECK, 1500, Process);
SetTimer(IID_CONNECTION_CHECK, 1000, Process);
SetTimer(IID_PING_CHECK, 9000, Process);
CWnd* pwndPropSheetHolder = GetDlgItem(IDC_SHEETHOLDER_PIC);
// WS_EX_CONTROLPARENT 속성을 주지 않으면 무한 루프도는 경우가 있음
pwndPropSheetHolder->ModifyStyleEx(0, WS_EX_CONTROLPARENT);
CRect rectPropSheet; pwndPropSheetHolder->GetWindowRect(rectPropSheet);
m_pMonitoringSheet = new CMonitoringSheet(_T("Chatting"), pwndPropSheetHolder);
if(!m_pMonitoringSheet->Create(pwndPropSheetHolder, WS_CHILD | WS_VISIBLE, 0))
{
delete m_pMonitoringSheet;
m_pMonitoringSheet = NULL;
return FALSE;
}
m_pMonitoringSheet->ModifyStyleEx(0, WS_EX_CONTROLPARENT); // 위와 같은 이유
m_pMonitoringSheet->SetWindowPos(NULL, 0, 0, rectPropSheet.Width(), rectPropSheet.Height(),
SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
SetDlgItemText(IDC_STRING018_STATIC, GetMyINIString("LOCAL_STRING", "STRING_018"));
SetDlgItemText(IDC_AUTH_BTN, GetMyINIString("LOCAL_STRING", "STRING_019"));
// 관리서버, 채팅서버 연결
ClientNet::CManagerServerEventHandler::Connect();
ClientNet::CChatServerEventHandler::Connect();
m_pFilterUser = new CFilterUserDialog(this);
m_pFilterUser->Create(IDD_FILTERDIALOG);
m_pGMReport = new CGMReportDialog(this);
m_pGMReport->Create(IDD_GMREPORTDIALOG);
return TRUE;
}
void CMonitoringToolDlg::OnBnClickedAuthBtn()
{
CLoginDlg dlg(CLoginDlg::CHAT_SERVER);
dlg.DoModal();
}
void CMonitoringToolDlg::ReportWorkResult(const char* szMsg)
{
m_ctrlReportList.InsertString(m_ctrlReportList.GetCount(), szMsg);
m_ctrlReportList.SetTopIndex(m_ctrlReportList.GetCount() - 4);
}
LRESULT CMonitoringToolDlg::OnShowMessageBox(WPARAM wParam, LPARAM lParam)
{
/*
switch(wParam)
{
case MSGBOX_MANAGER_DISCONNECTED:
// 관리서버와 연결 끊겼을때, 메시지박스 표시 : 관리서버와 연결이 끊겼습니다.
AfxMessageBox(GetMyINIString("LOCAL_STRING", "STRING_020"), MB_OK);z
break;
}
*/
return 0;
}
void CMonitoringToolDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
CRect rect, rectc;
GetClientRect(rect);
CWnd* pwndStatic = GetDlgItem(IDC_STRING018_STATIC);
pwndStatic->GetWindowRect(rectc);
pwndStatic->MoveWindow(rect.left+10, rect.bottom-70, rectc.Width(), rectc.Height());
CWnd* pwndAuth = GetDlgItem(IDC_AUTH_BTN);
pwndAuth->GetWindowRect(rectc);
pwndAuth->MoveWindow(rect.right-rectc.Width()-10, rect.bottom-80, rectc.Width(), rectc.Height());
CWnd* pwndFilter = GetDlgItem(IDC_FILTER_BTN);
pwndFilter->GetWindowRect(rectc);
pwndFilter->MoveWindow(rect.right-rectc.Width()-10, rect.bottom-55, rectc.Width(), rectc.Height());
CWnd* pwndReport = GetDlgItem(IDC_REPORT_BTN);
pwndReport->GetWindowRect(rectc);
pwndReport->MoveWindow(rect.right-rectc.Width()-10, rect.bottom-30, rectc.Width(), rectc.Height());
m_ctrlReportList.GetWindowRect(rectc);
m_ctrlReportList.MoveWindow(rect.left+170, rect.bottom-70, rect.Width()-450, rectc.Height());
CWnd* pwndPropSheetHolder = GetDlgItem(IDC_SHEETHOLDER_PIC);
pwndPropSheetHolder->GetWindowRect(rectc);
pwndPropSheetHolder->MoveWindow(rect.left+10, rect.top+10, rect.Width()-20, rect.Height()-95);
if(m_pMonitoringSheet)
{
pwndPropSheetHolder->GetClientRect(rectc);
m_pMonitoringSheet->MoveWindow(rectc);
}
// m_pMonitoringSheet->SetWindowPos(NULL, 0, 0, rectPropSheet.Width(), rectPropSheet.Height(),
/*
m_pMonitoringSheet = new CMonitoringSheet(_T("Chatting"), pwndPropSheetHolder);
if(!m_pMonitoringSheet->Create(pwndPropSheetHolder, WS_CHILD | WS_VISIBLE, 0))
{
delete m_pMonitoringSheet;
m_pMonitoringSheet = NULL;
return FALSE;
}
m_pMonitoringSheet->ModifyStyleEx(0, WS_EX_CONTROLPARENT); // 위와 같은 이유
SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
SetDlgItemText(IDC_STRING018_STATIC, GetMyINIString("LOCAL_STRING", "STRING_018"));
SetDlgItemText(IDC_AUTH_BTN, GetMyINIString("LOCAL_STRING", "STRING_019"));
*/
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
}
void CMonitoringToolDlg::OnBnClickedFilterBtn()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
if(m_pFilterUser)
{
if(m_pFilterUser->IsWindowVisible())
m_pFilterUser->ShowWindow(SW_HIDE);
else
m_pFilterUser->ShowWindow(SW_SHOW);
}
}
void CMonitoringToolDlg::OnBnClickedReportBtn()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
if(m_pGMReport)
{
if(m_pGMReport->IsWindowVisible())
m_pGMReport->ShowWindow(SW_HIDE);
else
m_pGMReport->ShowWindow(SW_SHOW);
}
}