[fix] close remote stream tabs after host disconnects

This commit is contained in:
dijunkun
2026-10-09 09:25:39 +08:00
parent 6d9230ff91
commit dacdbc5c45
6 changed files with 32 additions and 2 deletions
@@ -308,7 +308,13 @@ void GuiRuntime::CloseServerController(const std::string& remote_id) {
if (!peer_ || remote_id.empty() || controller_cleanup_tasks_.count(remote_id))
return;
controller_cleanup_tasks_[remote_id] = session_cleanup_queue_.PostTask(
[peer = peer_, remote_id] { LeaveConnection(peer, remote_id.c_str()); });
[peer = peer_, transmission_id = std::string(client_id_), remote_id] {
if (DisconnectPeerConnection(peer, transmission_id.c_str(),
remote_id.c_str()) != 0) {
LOG_WARN("[{}] Could not queue controller disconnect notification",
remote_id);
}
});
}
void GuiRuntime::CloseConnectionPeer() {
@@ -379,6 +379,10 @@ void PeerEventHandler::OnConnectionStatus(ConnectionStatus status,
runtime->focus_on_stream_window_ = false;
if (status == ConnectionStatus::Closed) {
props->remote_close_pending_.store(true, std::memory_order_release);
}
break;
}
case ConnectionStatus::IncorrectPassword: {
@@ -73,6 +73,8 @@ struct RemoteSession {
PeerPtr* peer_ = nullptr;
std::shared_ptr<PeerEventHandler> peer_events_;
std::atomic<bool> closing_{false};
// Transport callbacks request tab closure; only the UI thread destroys it.
std::atomic<bool> remote_close_pending_{false};
std::string audio_label_ = kAudioStream;
std::string data_label_ = kDataStream;
std::string mouse_label_ = kMouseStream;