Feat: Android client Phase 0-3 full implementation
This commit is contained in:
@@ -1485,13 +1485,19 @@ VOID CMy2015RemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName
|
||||
if (TryMigrateClientMetadata(id, strPCName, path)) {
|
||||
modify = true;
|
||||
}
|
||||
CString loc = m_ClientMap->GetClientMapData(id, MAP_LOCATION);
|
||||
if (loc.IsEmpty()) {
|
||||
loc = v[RES_CLIENT_LOC].c_str();
|
||||
if (loc.IsEmpty()) {
|
||||
loc = m_IPConverter->GetGeoLocation(data[ONLINELIST_IP].GetString()).c_str();
|
||||
needConvert = !m_HasLocDB;
|
||||
}
|
||||
// 优先级:① 客户端刚发来的有效地理位置(非空非"?")
|
||||
// ② 服务端缓存(排除历史遗留的"?"无效值)
|
||||
// ③ 服务端按连接 IP 自行查询
|
||||
CString clientLoc = v[RES_CLIENT_LOC].c_str();
|
||||
CString cachedLoc = m_ClientMap->GetClientMapData(id, MAP_LOCATION);
|
||||
CString loc;
|
||||
if (!clientLoc.IsEmpty() && clientLoc != "?") {
|
||||
loc = clientLoc;
|
||||
} else if (!cachedLoc.IsEmpty() && cachedLoc != "?") {
|
||||
loc = cachedLoc;
|
||||
} else {
|
||||
loc = m_IPConverter->GetGeoLocation(data[ONLINELIST_IP].GetString()).c_str();
|
||||
needConvert = !m_HasLocDB;
|
||||
}
|
||||
// TODO: Remove SafeUtf8ToAnsi after migrating to UTF-8
|
||||
if (needConvert)
|
||||
@@ -3478,7 +3484,7 @@ void CMy2015RemoteDlg::CheckHeartbeat()
|
||||
{
|
||||
CLock lock(m_cs);
|
||||
auto now = time(0);
|
||||
int HEARTBEAT_TIMEOUT = max(60, m_settings.ReportInterval * 3);
|
||||
int HEARTBEAT_TIMEOUT = max(120, m_settings.ReportInterval * 3);
|
||||
|
||||
// 收集需要删除的 context(避免遍历时修改 vector)
|
||||
std::vector<context*> toRemove;
|
||||
@@ -10304,6 +10310,17 @@ context* CMy2015RemoteDlg::FindHostByIP(const std::string& ip)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
context* CMy2015RemoteDlg::FindHostByClientID(uint64_t clientID)
|
||||
{
|
||||
EnterCriticalSection(&m_cs);
|
||||
auto it = m_ClientIndex.find(clientID);
|
||||
context* ctx = nullptr;
|
||||
if (it != m_ClientIndex.end() && it->second < m_HostList.size())
|
||||
ctx = m_HostList[it->second];
|
||||
LeaveCriticalSection(&m_cs);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
uint64_t CMy2015RemoteDlg::FindClientIDByIP(const std::string& ip)
|
||||
{
|
||||
CString clientIP(ip.c_str());
|
||||
|
||||
Reference in New Issue
Block a user