[feat] attempt to rejoin once per second

This commit is contained in:
dijunkun
2025-11-27 04:20:29 +08:00
parent 217cfb091d
commit 239da373d0
3 changed files with 16 additions and 6 deletions

View File

@@ -101,12 +101,21 @@ int Render::RemoteWindow() {
} }
} }
// check every 1 second for rejoin
if (need_to_rejoin_) { if (need_to_rejoin_) {
need_to_rejoin_ = false; auto now = std::chrono::steady_clock::now();
for (const auto& [_, props] : client_properties_) { auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
if (props->rejoin_) { now - last_rejoin_check_time_)
ConnectTo(props->remote_id_, props->remote_password_, .count();
props->remember_password_);
if (elapsed >= 1000) {
last_rejoin_check_time_ = now;
need_to_rejoin_ = false;
for (const auto& [_, props] : client_properties_) {
if (props->rejoin_) {
ConnectTo(props->remote_id_, props->remote_password_,
props->remember_password_);
}
} }
} }
} }

View File

@@ -168,7 +168,7 @@ SDL_HitTestResult Render::HitTestCallback(SDL_Window* window,
return SDL_HITTEST_NORMAL; return SDL_HITTEST_NORMAL;
} }
Render::Render() {} Render::Render() : last_rejoin_check_time_(std::chrono::steady_clock::now()) {}
Render::~Render() {} Render::~Render() {}

View File

@@ -379,6 +379,7 @@ class Render {
int audio_len_ = 0; int audio_len_ = 0;
bool audio_buffer_fresh_ = false; bool audio_buffer_fresh_ = false;
bool need_to_rejoin_ = false; bool need_to_rejoin_ = false;
std::chrono::steady_clock::time_point last_rejoin_check_time_;
bool just_created_ = false; bool just_created_ = false;
std::string controlled_remote_id_ = ""; std::string controlled_remote_id_ = "";
std::string focused_remote_id_ = ""; std::string focused_remote_id_ = "";