rdp: quit when dbus service is gone

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2024-07-28 11:47:08 +04:00
parent b66058aefb
commit 6ad37b1f61
3 changed files with 19 additions and 1 deletions

View File

@ -209,6 +209,10 @@ impl<'d> Display<'d> {
.await
}
pub fn inner_proxy(&self) -> &zbus::Proxy<'d> {
self.inner.proxy.inner()
}
pub async fn receive_owner_changed(&self) -> Result<OwnerChangedStream<'_>> {
Ok(self.inner.proxy.inner().receive_owner_changed().await?)
}

View File

@ -25,3 +25,4 @@ ironrdp = { git = "https://github.com/Devolutions/IronRDP", features = [
"displaycontrol",
"rdpsnd"
] }
futures-util = "0.3"

View File

@ -4,7 +4,10 @@ mod input;
mod sound;
use anyhow::{anyhow, Context, Error};
use ironrdp::server::tokio_rustls::{rustls, TlsAcceptor};
use ironrdp::server::{
tokio_rustls::{rustls, TlsAcceptor},
ServerEvent,
};
use qemu_display::{zbus, Display};
use rustls_pemfile::{certs, pkcs8_private_keys};
@ -61,6 +64,16 @@ impl Server {
.with_sound_factory(sound.map(|h| Box::new(h) as _))
.build();
let ev = server.event_sender().clone();
let proxy = dbus_display.inner_proxy().clone();
tokio::spawn(async move {
use futures_util::StreamExt;
let mut owner_changed = proxy.receive_owner_changed().await.unwrap();
let _ = owner_changed.next().await;
ev.send(ServerEvent::Quit("org.qemu is gone".to_owned()))
.unwrap();
});
server.run().await
}
}