mirror of
https://github.com/yuanyuanxiang/SimpleRemoter.git
synced 2026-01-21 23:13:08 +08:00
Feature: Add a startup progress display to the program
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
|
||||
// 2015Remote.h : PROJECT_NAME Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD>
|
||||
|
||||
// 2015Remote.h : PROJECT_NAME 应用程序的主头文件
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error "<EFBFBD>ڰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>֮ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>stdafx.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> PCH <EFBFBD>ļ<EFBFBD>"
|
||||
#error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
|
||||
#endif
|
||||
|
||||
#include "resource.h" // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#include "resource.h" // 主符号
|
||||
#include "common/iniFile.h"
|
||||
#include "IOCPServer.h"
|
||||
#include "IOCPUDPServer.h"
|
||||
#include "IOCPKCPServer.h"
|
||||
|
||||
// CMy2015RemoteApp:
|
||||
// <EFBFBD>йش<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>֣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2015Remote.cpp
|
||||
// 有关此类的实现,请参阅 2015Remote.cpp
|
||||
//
|
||||
|
||||
// ServerPair:
|
||||
// һ<EFBFBD><EFBFBD>SOCKET<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>: ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD>TCP<EFBFBD><EFBFBD>UDP.
|
||||
// 一对SOCKET服务端,监听端口: 同时监听TCP和UDP.
|
||||
class ServerPair
|
||||
{
|
||||
private:
|
||||
@@ -38,11 +38,11 @@ public:
|
||||
BOOL StartServer(pfnNotifyProc NotifyProc, pfnOfflineProc OffProc, USHORT uPort)
|
||||
{
|
||||
UINT ret1 = m_tcpServer->StartServer(NotifyProc, OffProc, uPort);
|
||||
if (ret1) MessageBox(NULL, CString("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>TCP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>: ") + std::to_string(uPort).c_str()
|
||||
+ CString("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ") + std::to_string(ret1).c_str(), "<EFBFBD><EFBFBD>ʾ", MB_ICONINFORMATION);
|
||||
if (ret1) MessageBox(NULL, CString("启动TCP服务失败: ") + std::to_string(uPort).c_str()
|
||||
+ CString("。错误码: ") + std::to_string(ret1).c_str(), "提示", MB_ICONINFORMATION);
|
||||
UINT ret2 = m_udpServer->StartServer(NotifyProc, OffProc, uPort);
|
||||
if (ret2) MessageBox(NULL, CString("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>UDP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>: ") + std::to_string(uPort).c_str()
|
||||
+ CString("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ") + std::to_string(ret2).c_str(), "<EFBFBD><EFBFBD>ʾ", MB_ICONINFORMATION);
|
||||
if (ret2) MessageBox(NULL, CString("启动UDP服务失败: ") + std::to_string(uPort).c_str()
|
||||
+ CString("。错误码: ") + std::to_string(ret2).c_str(), "提示", MB_ICONINFORMATION);
|
||||
return (ret1 == 0 || ret2 == 0);
|
||||
}
|
||||
|
||||
@@ -65,21 +65,29 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class CSplashDlg; // 前向声明
|
||||
|
||||
class CMy2015RemoteApp : public CWinApp
|
||||
{
|
||||
private:
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>
|
||||
// 配置文件读取器
|
||||
config* m_iniFile = nullptr;
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||
// 服务端对象列表
|
||||
std::vector<ServerPair*> m_iocpServer;
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// 互斥量
|
||||
HANDLE m_Mutex = nullptr;
|
||||
// 启动画面
|
||||
CSplashDlg* m_pSplash = nullptr;
|
||||
|
||||
public:
|
||||
CMy2015RemoteApp();
|
||||
|
||||
CImageList m_pImageList_Large; //ϵͳ<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>
|
||||
CImageList m_pImageList_Small; //ϵͳСͼ<EFBFBD><EFBFBD>
|
||||
CImageList m_pImageList_Large; // 系统大图标
|
||||
CImageList m_pImageList_Small; // 系统小图标
|
||||
|
||||
// 获取启动画面指针
|
||||
CSplashDlg* GetSplash() const { return m_pSplash; }
|
||||
void SetSplash(CSplashDlg* pSplash) { m_pSplash = pSplash; }
|
||||
|
||||
virtual BOOL InitInstance();
|
||||
|
||||
@@ -88,8 +96,8 @@ public:
|
||||
return m_iniFile;
|
||||
}
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0
|
||||
// nPortʾ<EFBFBD><EFBFBD>: 6543;7543
|
||||
// 启动多个服务端,成功返回0
|
||||
// nPort示例: 6543;7543
|
||||
UINT StartServer(pfnNotifyProc NotifyProc, pfnOfflineProc OffProc, const std::string& uPort, int maxConn, const std::string& method)
|
||||
{
|
||||
bool succeed = false;
|
||||
@@ -111,7 +119,7 @@ public:
|
||||
return succeed ? 0 : -1;
|
||||
}
|
||||
|
||||
// <EFBFBD>ͷŷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SOCKET
|
||||
// 释放服务端 SOCKET
|
||||
void Destroy()
|
||||
{
|
||||
for (int i=0; i<m_iocpServer.size(); ++i) {
|
||||
@@ -119,7 +127,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// <EFBFBD>ͷŷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
||||
// 释放服务端指针
|
||||
void Delete()
|
||||
{
|
||||
for (int i = 0; i < m_iocpServer.size(); ++i) {
|
||||
@@ -128,7 +136,7 @@ public:
|
||||
m_iocpServer.clear();
|
||||
}
|
||||
|
||||
// <EFBFBD><EFBFBD><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) {
|
||||
|
||||
Reference in New Issue
Block a user