layout: Refactor the socket server code
This commit is contained in:
@@ -18,20 +18,62 @@
|
||||
|
||||
class CMy2015RemoteApp : public CWinApp
|
||||
{
|
||||
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>
|
||||
std::vector<Server*> m_iocpServer;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
HANDLE m_Mutex = nullptr;
|
||||
|
||||
public:
|
||||
CMy2015RemoteApp();
|
||||
config *m_iniFile;
|
||||
HANDLE m_Mutex;
|
||||
Server* m_iocpServer;
|
||||
|
||||
CImageList m_pImageList_Large; //ϵͳ<CFB5><CDB3>ͼ<EFBFBD><CDBC>
|
||||
CImageList m_pImageList_Small; //ϵͳСͼ<D0A1><CDBC>
|
||||
|
||||
// <20><>д
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
|
||||
// ʵ<><CAB5>
|
||||
config* GetCfg() const {
|
||||
return m_iniFile;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>0
|
||||
UINT StartServer(pfnNotifyProc NotifyProc, pfnOfflineProc OffProc, USHORT uPort) {
|
||||
auto svr = new IOCPServer();
|
||||
UINT ret = svr->StartServer(NotifyProc, OffProc, uPort);
|
||||
if (ret != 0) {
|
||||
SAFE_DELETE(svr);
|
||||
return ret;
|
||||
}
|
||||
m_iocpServer.push_back(svr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// <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);
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
virtual int ExitInstance();
|
||||
|
||||
Reference in New Issue
Block a user