mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-10-15 00:09:39 +08:00
[fix] delay signaling offline indication during reconnects
This commit is contained in:
@@ -74,6 +74,10 @@ namespace {
|
|||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
|
// Median reconnect to the signal server lands around 7 s on a lossy path, so a
|
||||||
|
// drop shorter than this is almost always already being recovered from.
|
||||||
|
constexpr auto kSignalOfflineGrace = 10s;
|
||||||
|
|
||||||
std::optional<std::string> GenerateRandomPassword(std::string_view current) {
|
std::optional<std::string> GenerateRandomPassword(std::string_view current) {
|
||||||
constexpr std::string_view alphabet =
|
constexpr std::string_view alphabet =
|
||||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
@@ -2471,7 +2475,21 @@ void GuiApplication::SyncMainWindow() {
|
|||||||
std::lock_guard<std::mutex> lock(password_change_mutex_);
|
std::lock_guard<std::mutex> lock(password_change_mutex_);
|
||||||
ui_->main->set_password_change_pending(password_change_pending_);
|
ui_->main->set_password_change_pending(password_change_pending_);
|
||||||
}
|
}
|
||||||
ui_->main->set_signal_connected(signal_connected_);
|
const bool signal_online = signal_connected_.load();
|
||||||
|
if (signal_online) {
|
||||||
|
signal_lost_at_valid_ = false;
|
||||||
|
} else if (!signal_lost_at_valid_) {
|
||||||
|
signal_lost_at_ = std::chrono::steady_clock::now();
|
||||||
|
signal_lost_at_valid_ = true;
|
||||||
|
}
|
||||||
|
// Reconnects routinely take several seconds on a lossy path; only report
|
||||||
|
// offline once the connection has stayed down long enough to be a real
|
||||||
|
// outage rather than a blip the reconnect is already recovering from.
|
||||||
|
const bool signal_offline =
|
||||||
|
!signal_online && signal_lost_at_valid_ &&
|
||||||
|
std::chrono::steady_clock::now() - signal_lost_at_ >
|
||||||
|
kSignalOfflineGrace;
|
||||||
|
ui_->main->set_signal_connected(!signal_offline);
|
||||||
ui_->main->set_signal_tls_error(signal_status_ ==
|
ui_->main->set_signal_tls_error(signal_status_ ==
|
||||||
SignalStatus::SignalTlsCertError);
|
SignalStatus::SignalTlsCertError);
|
||||||
ui_->main->set_update_available(update_available_);
|
ui_->main->set_update_available(update_available_);
|
||||||
|
|||||||
@@ -106,6 +106,11 @@ private:
|
|||||||
cursor_delivery_states_;
|
cursor_delivery_states_;
|
||||||
uint32_t cursor_state_sequence_ = 0;
|
uint32_t cursor_state_sequence_ = 0;
|
||||||
std::chrono::steady_clock::time_point next_video_frame_time_{};
|
std::chrono::steady_clock::time_point next_video_frame_time_{};
|
||||||
|
// The signal server is reached over a lossy path that routinely drops for the
|
||||||
|
// few seconds a reconnect takes, so the main window holds its "connected"
|
||||||
|
// indication through a brief blip instead of flickering offline.
|
||||||
|
std::chrono::steady_clock::time_point signal_lost_at_{};
|
||||||
|
bool signal_lost_at_valid_ = false;
|
||||||
#if defined(__linux__) && !defined(__APPLE__)
|
#if defined(__linux__) && !defined(__APPLE__)
|
||||||
bool use_xwayland_gui_ = false;
|
bool use_xwayland_gui_ = false;
|
||||||
bool use_x11_custom_titlebar_ = false;
|
bool use_x11_custom_titlebar_ = false;
|
||||||
|
|||||||
Vendored
+1
-1
Submodule deps/submodules/minirtc updated: c44807de57...23b5b02cc8
Reference in New Issue
Block a user