From e61894bd4e09138f24b47a58218d1884cacf6e38 Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Wed, 10 Apr 2024 07:28:37 +0200 Subject: [PATCH] AbstractRunner: exit when NetImgui disconnected --- .../internal/backend_impls/abstract_runner.cpp | 10 +++++++++- .../netimgui_remote_display.cpp | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp index 600e9537..650d486f 100644 --- a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp +++ b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp @@ -870,8 +870,16 @@ void AbstractRunner::CreateFramesAndRender() constexpr bool foldable_region = true; #ifdef HELLOIMGUI_WITH_NETIMGUI - if (params.remoteParams.enableRemoting) + if (params.remoteParams.enableRemoting) // Hande NetImGui connection + { NetImGui_LogConnectionStatusOnce(); + if (!NetImgui::IsConnected()) + { + // Maybe we should wait for a few frames before we exit. + printf("NetImGui: Not connected anymore, exiting app\n"); + params.appShallExit = true; + } + } #endif if (foldable_region) // Update frame rate stats diff --git a/src/netimgui_remote_display/netimgui_remote_display.cpp b/src/netimgui_remote_display/netimgui_remote_display.cpp index 03b75020..01089355 100644 --- a/src/netimgui_remote_display/netimgui_remote_display.cpp +++ b/src/netimgui_remote_display/netimgui_remote_display.cpp @@ -77,7 +77,7 @@ int main(int argc, char **argv) handle_dpi_awareness(); }; - runnerParams.callbacks.BeforeImGuiRender = []() { + runnerParams.callbacks.ShowGui = []() { ImVec4 clear_color = NetImguiServer::UI::DrawImguiContent(); HelloImGui::GetRunnerParams()->imGuiWindowParams.backgroundColor = clear_color; };