mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:17:34 +00:00
SpiceAgent: Gracefully exit when the Spice server disconnects
This commit is contained in:
parent
36d61c01bc
commit
35fdc7f8c8
3 changed files with 13 additions and 1 deletions
|
@ -217,6 +217,12 @@ ErrorOr<void> SpiceAgent::on_message_received()
|
||||||
dbgln_if(SPICE_AGENT_DEBUG, "Ignored message: {}", header);
|
dbgln_if(SPICE_AGENT_DEBUG, "Ignored message: {}", header);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Message::Type::Disconnected:
|
||||||
|
dbgln_if(SPICE_AGENT_DEBUG, "Spice server disconnected");
|
||||||
|
if (on_disconnected_from_spice_server)
|
||||||
|
on_disconnected_from_spice_server();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
dbgln("Unknown message received: {}", header);
|
dbgln("Unknown message received: {}", header);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -62,6 +62,8 @@ public:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function<void()> on_disconnected_from_spice_server;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NonnullOwnPtr<Core::File> m_spice_device;
|
NonnullOwnPtr<Core::File> m_spice_device;
|
||||||
Vector<Capability> m_capabilities;
|
Vector<Capability> m_capabilities;
|
||||||
|
|
|
@ -35,7 +35,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
TRY(Core::System::unveil(nullptr, nullptr));
|
TRY(Core::System::unveil(nullptr, nullptr));
|
||||||
|
|
||||||
auto agent = TRY(SpiceAgent::SpiceAgent::create(SPICE_DEVICE));
|
auto agent = TRY(SpiceAgent::SpiceAgent::create(SPICE_DEVICE));
|
||||||
TRY(agent->start());
|
|
||||||
|
|
||||||
|
agent->on_disconnected_from_spice_server = [&]() {
|
||||||
|
app->quit();
|
||||||
|
};
|
||||||
|
|
||||||
|
TRY(agent->start());
|
||||||
return app->exec();
|
return app->exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue