From 6a1e0810abf74501840ea8c23f25ba228c7fc670 Mon Sep 17 00:00:00 2001 From: shaun <962914132@qq.com> Date: Wed, 21 Jan 2026 17:33:51 +0100 Subject: [PATCH] Fix: `GetPort` issue causing not show host offline log --- server/2015Remote/2015RemoteDlg.cpp | 18 +++++++++++------- server/2015Remote/Server.h | 5 ++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/server/2015Remote/2015RemoteDlg.cpp b/server/2015Remote/2015RemoteDlg.cpp index bb2e9e8..26fb16f 100644 --- a/server/2015Remote/2015RemoteDlg.cpp +++ b/server/2015Remote/2015RemoteDlg.cpp @@ -1890,6 +1890,7 @@ void CMy2015RemoteDlg::OnOnlineDelete() ctx->Destroy(); strIP+="断开连接"; ShowMessage("操作成功",strIP + "[" + aliveInfo.c_str() + "]"); + Mprintf("%s 断开链接 [%s]\n", strIP, aliveInfo.c_str()); } LeaveCriticalSection(&m_cs); } @@ -2814,25 +2815,28 @@ LRESULT CMy2015RemoteDlg::OnUserOfflineMsg(WPARAM wParam, LPARAM lParam) return S_OK; } - CString ip, port; + CString port; port.Format("%d", lParam); EnterCriticalSection(&m_cs); int n = m_CList_Online.GetItemCount(); for (int i = 0; i < n; ++i) { CString cur = m_CList_Online.GetItemText(i, ONLINELIST_ADDR); if (cur == port) { - ip = m_CList_Online.GetItemText(i, ONLINELIST_IP); auto ctx = (context*)m_CList_Online.GetItemData(i); m_CList_Online.DeleteItem(i); m_HostList.erase(ctx); - auto tm = ctx->GetAliveTime(); - std::string aliveInfo = tm>=86400 ? floatToString(tm / 86400.f) + " d" : - tm >= 3600 ? floatToString(tm / 3600.f) + " h" : - tm >= 60 ? floatToString(tm / 60.f) + " m" : floatToString(tm) + " s"; - ShowMessage("操作成功", ip + "主机下线[" + aliveInfo.c_str() + "]"); break; } } + if (host) { + CString ip = host->GetClientData(ONLINELIST_IP); + auto tm = host->GetAliveTime(); + std::string aliveInfo = tm >= 86400 ? floatToString(tm / 86400.f) + " d" : + tm >= 3600 ? floatToString(tm / 3600.f) + " h" : + tm >= 60 ? floatToString(tm / 60.f) + " m" : floatToString(tm) + " s"; + ShowMessage("操作成功", ip + "主机下线[" + aliveInfo.c_str() + "]"); + Mprintf("%s 主机下线 [%s]\n", ip, aliveInfo.c_str()); + } LeaveCriticalSection(&m_cs); if (p && ::IsWindow(p->GetSafeHwnd())) { diff --git a/server/2015Remote/Server.h b/server/2015Remote/Server.h index f390e23..4f312ba 100644 --- a/server/2015Remote/Server.h +++ b/server/2015Remote/Server.h @@ -527,7 +527,10 @@ public: } virtual int GetPort() const { - return sClientSocket; + // 第一次返回套接字,后续返回地址栏端口号 + if (sClientInfo[ONLINELIST_ADDR].IsEmpty()) + return sClientSocket; + return atoi(sClientInfo[ONLINELIST_ADDR]); } CString GetClientData(int index) const override {