feat: Add showing client version and start time
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
#include "LoginServer.h"
|
||||
#include "Common.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <ctime>
|
||||
|
||||
/************************************************************************
|
||||
---------------------
|
||||
@@ -122,10 +125,39 @@ std::string getSystemName()
|
||||
return vname;
|
||||
}
|
||||
|
||||
std::string formatTime(const FILETIME& fileTime) {
|
||||
// ת<><D7AA>Ϊ 64 λʱ<CEBB><CAB1>
|
||||
ULARGE_INTEGER ull;
|
||||
ull.LowPart = fileTime.dwLowDateTime;
|
||||
ull.HighPart = fileTime.dwHighDateTime;
|
||||
|
||||
// ת<><D7AA>Ϊ<EFBFBD>뼶ʱ<EBBCB6><CAB1><EFBFBD><EFBFBD>
|
||||
std::time_t startTime = static_cast<std::time_t>((ull.QuadPart / 10000000ULL) - 11644473600ULL);
|
||||
|
||||
// <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
std::tm* localTime = std::localtime(&startTime);
|
||||
char buffer[100];
|
||||
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", localTime);
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
std::string getProcessTime() {
|
||||
FILETIME creationTime, exitTime, kernelTime, userTime;
|
||||
|
||||
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>̵<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ϣ
|
||||
if (GetProcessTimes(GetCurrentProcess(), &creationTime, &exitTime, &kernelTime, &userTime)) {
|
||||
return formatTime(creationTime);
|
||||
}
|
||||
std::time_t now = std::time(nullptr);
|
||||
std::tm* t = std::localtime(&now);
|
||||
char buffer[100];
|
||||
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", t);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed)
|
||||
{
|
||||
LOGIN_INFOR LoginInfor = {0};
|
||||
LOGIN_INFOR LoginInfor;
|
||||
LoginInfor.bToken = TOKEN_LOGIN; // <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>¼
|
||||
//<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>ϵͳ<CFB5><CDB3>Ϣ
|
||||
strcpy_s(LoginInfor.OsVerInfoEx, getSystemName().c_str());
|
||||
@@ -148,9 +180,8 @@ int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed)
|
||||
memcpy(LoginInfor.szPCName,szPCName,MAX_PATH);
|
||||
LoginInfor.dwSpeed = dwSpeed;
|
||||
LoginInfor.dwCPUMHz = dwCPUMHz;
|
||||
LoginInfor.ClientAddr = ClientAddr.sin_addr;
|
||||
LoginInfor.bWebCamIsExist = bWebCamIsExist;
|
||||
|
||||
strcpy_s(LoginInfor.szStartTime, getProcessTime().c_str());
|
||||
int iRet = ClientObject->OnServerSending((char*)&LoginInfor, sizeof(LOGIN_INFOR));
|
||||
|
||||
return iRet;
|
||||
|
||||
Reference in New Issue
Block a user