[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,7 +101,15 @@ int Render::RemoteWindow() {
} }
} }
// check every 1 second for rejoin
if (need_to_rejoin_) { if (need_to_rejoin_) {
auto now = std::chrono::steady_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
now - last_rejoin_check_time_)
.count();
if (elapsed >= 1000) {
last_rejoin_check_time_ = now;
need_to_rejoin_ = false; need_to_rejoin_ = false;
for (const auto& [_, props] : client_properties_) { for (const auto& [_, props] : client_properties_) {
if (props->rejoin_) { if (props->rejoin_) {
@@ -111,6 +119,7 @@ int Render::RemoteWindow() {
} }
} }
} }
}
ImGui::EndChild(); ImGui::EndChild();
} }
ImGui::EndChild(); ImGui::EndChild();

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_ = "";