[fix] isolate background connections and password retries

This commit is contained in:
dijunkun
2026-10-12 03:08:00 +08:00
parent c8907a00f9
commit 54dbd04a8d
8 changed files with 96 additions and 37 deletions
@@ -16,22 +16,25 @@ namespace crossdesk {
inline nlohmann::json BuildDevicePresenceRequest(
const std::string& client_id, const std::vector<std::string>& recent_ids,
bool subscribe, const std::string& probe_id = {}) {
bool subscribe, const std::string& probe_id = {},
const std::vector<std::string>& additional_ids = {}) {
std::vector<std::string> devices;
for (const auto& id : recent_ids) {
const auto append = [&](const std::string& id) {
// Recent connection keys contain Y/N plus display settings after the ID.
const std::string pure_id = id.substr(0, id.find_first_of("YN"));
if (!pure_id.empty() &&
std::find(devices.begin(), devices.end(), pure_id) == devices.end()) {
devices.push_back(pure_id);
}
}
};
for (const auto& id : recent_ids) append(id);
for (const auto& id : additional_ids) append(id);
if (!probe_id.empty() &&
std::find(devices.begin(), devices.end(), probe_id) == devices.end()) {
devices.push_back(probe_id);
}
// Include recent devices even in a one-shot probe: older servers ignore
// subscribe=false and replace their subscriptions with this device list.
// Keep recent and wall devices even in a one-shot probe: older servers
// ignore subscribe=false and replace subscriptions with this device list.
return {{"type", "recent_connections_presence"},
{"user_id", client_id},
{"devices", devices},
@@ -40,4 +43,4 @@ inline nlohmann::json BuildDevicePresenceRequest(
} // namespace crossdesk
#endif
#endif