2019-01-05 20:21:43 +08:00
|
|
|
|
|
|
|
|
|
|
// 2015Remote.h : PROJECT_NAME Ӧ<>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD>
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __AFXWIN_H__
|
|
|
|
|
|
#error "<22>ڰ<EFBFBD><DAB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>stdafx.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> PCH <20>ļ<EFBFBD>"
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include "resource.h" // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-18 04:22:48 +08:00
|
|
|
|
#include "common/iniFile.h"
|
2025-04-07 18:18:36 +08:00
|
|
|
|
#include "IOCPServer.h"
|
2025-07-01 04:01:10 +08:00
|
|
|
|
#include "IOCPUDPServer.h"
|
2019-01-05 20:21:43 +08:00
|
|
|
|
|
|
|
|
|
|
// CMy2015RemoteApp:
|
|
|
|
|
|
// <20>йش<D0B9><D8B4><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2015Remote.cpp
|
|
|
|
|
|
//
|
|
|
|
|
|
|
2025-07-01 04:01:10 +08:00
|
|
|
|
// ServerPair:
|
|
|
|
|
|
// һ<><D2BB>SOCKET<45><54><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>: ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD>TCP<43><50>UDP.
|
|
|
|
|
|
class ServerPair
|
|
|
|
|
|
{
|
|
|
|
|
|
private:
|
|
|
|
|
|
Server* m_tcpServer;
|
|
|
|
|
|
Server* m_udpServer;
|
|
|
|
|
|
public:
|
|
|
|
|
|
ServerPair() : m_tcpServer(new IOCPServer), m_udpServer(new IOCPUDPServer) {}
|
|
|
|
|
|
virtual ~ServerPair() { SAFE_DELETE(m_tcpServer); SAFE_DELETE(m_udpServer); }
|
|
|
|
|
|
|
|
|
|
|
|
BOOL StartServer(pfnNotifyProc NotifyProc, pfnOfflineProc OffProc, USHORT uPort) {
|
|
|
|
|
|
UINT ret1 = m_tcpServer->StartServer(NotifyProc, OffProc, uPort);
|
|
|
|
|
|
UINT ret2 = m_udpServer->StartServer(NotifyProc, OffProc, uPort);
|
|
|
|
|
|
return (ret1 == 0 || ret2 == 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UpdateMaxConnection(int maxConn) {
|
|
|
|
|
|
if (m_tcpServer) m_tcpServer->UpdateMaxConnection(maxConn);
|
|
|
|
|
|
if (m_udpServer) m_udpServer->UpdateMaxConnection(maxConn);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Destroy() {
|
|
|
|
|
|
if (m_tcpServer) m_tcpServer->Destroy();
|
|
|
|
|
|
if (m_udpServer) m_udpServer->Destroy();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Disconnect(CONTEXT_OBJECT* ctx) {
|
|
|
|
|
|
if (m_tcpServer) m_tcpServer->Disconnect(ctx);
|
|
|
|
|
|
if (m_udpServer) m_udpServer->Disconnect(ctx);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2019-01-05 20:21:43 +08:00
|
|
|
|
class CMy2015RemoteApp : public CWinApp
|
|
|
|
|
|
{
|
2025-06-30 04:35:38 +08:00
|
|
|
|
private:
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ȡ<EFBFBD><C8A1>
|
|
|
|
|
|
config* m_iniFile = nullptr;
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
2025-07-01 04:01:10 +08:00
|
|
|
|
std::vector<ServerPair*> m_iocpServer;
|
2025-06-30 04:35:38 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
HANDLE m_Mutex = nullptr;
|
|
|
|
|
|
|
2019-01-05 20:21:43 +08:00
|
|
|
|
public:
|
|
|
|
|
|
CMy2015RemoteApp();
|
2025-06-28 23:52:26 +08:00
|
|
|
|
|
|
|
|
|
|
CImageList m_pImageList_Large; //ϵͳ<CFB5><CDB3>ͼ<EFBFBD><CDBC>
|
|
|
|
|
|
CImageList m_pImageList_Small; //ϵͳСͼ<D0A1><CDBC>
|
|
|
|
|
|
|
2019-01-05 20:21:43 +08:00
|
|
|
|
virtual BOOL InitInstance();
|
|
|
|
|
|
|
2025-06-30 04:35:38 +08:00
|
|
|
|
config* GetCfg() const {
|
|
|
|
|
|
return m_iniFile;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-01 04:01:10 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>0
|
|
|
|
|
|
// nPortʾ<74><CABE>: 6543;7543
|
|
|
|
|
|
UINT StartServer(pfnNotifyProc NotifyProc, pfnOfflineProc OffProc, const std::string& uPort) {
|
|
|
|
|
|
bool succeed = false;
|
|
|
|
|
|
auto list = StringToVector(uPort, ';');
|
|
|
|
|
|
for (int i=0; i<list.size(); ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
int port = std::atoi(list[i].c_str());
|
|
|
|
|
|
auto svr = new ServerPair();
|
|
|
|
|
|
BOOL ret = svr->StartServer(NotifyProc, OffProc, port);
|
|
|
|
|
|
if (ret == FALSE) {
|
|
|
|
|
|
SAFE_DELETE(svr);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
succeed = true;
|
|
|
|
|
|
m_iocpServer.push_back(svr);
|
2025-06-30 04:35:38 +08:00
|
|
|
|
}
|
2025-07-01 04:01:10 +08:00
|
|
|
|
|
|
|
|
|
|
return succeed ? 0 : -1;
|
2025-06-30 04:35:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20>ͷŷ<CDB7><C5B7><EFBFBD><EFBFBD><EFBFBD> SOCKET
|
|
|
|
|
|
void Destroy() {
|
|
|
|
|
|
for (int i=0; i<m_iocpServer.size(); ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iocpServer[i]->Destroy();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20>ͷŷ<CDB7><C5B7><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|
|
|
|
|
void Delete() {
|
|
|
|
|
|
for (int i = 0; i < m_iocpServer.size(); ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
SAFE_DELETE(m_iocpServer[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
m_iocpServer.clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void UpdateMaxConnection(int maxConn) {
|
|
|
|
|
|
for (int i = 0; i < m_iocpServer.size(); ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iocpServer[i]->UpdateMaxConnection(maxConn);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-01-05 20:21:43 +08:00
|
|
|
|
|
|
|
|
|
|
DECLARE_MESSAGE_MAP()
|
2019-01-13 00:04:50 +08:00
|
|
|
|
virtual int ExitInstance();
|
2019-01-05 20:21:43 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-06-18 04:22:48 +08:00
|
|
|
|
extern CMy2015RemoteApp theApp;
|
|
|
|
|
|
|
|
|
|
|
|
CMy2015RemoteApp* GetThisApp();
|
|
|
|
|
|
|
|
|
|
|
|
config& GetThisCfg();
|
|
|
|
|
|
|
|
|
|
|
|
#define THIS_APP GetThisApp()
|
|
|
|
|
|
|
|
|
|
|
|
#define THIS_CFG GetThisCfg()
|