Start/Stop IPC when changing the config setting

This commit is contained in:
Megamouse 2023-12-14 22:30:25 +01:00
parent 907e0fa8c8
commit f8e0c9e27a
2 changed files with 15 additions and 1 deletions

View File

@ -108,12 +108,14 @@ namespace IPC_socket
int port = g_cfg_ipc.get_port();
if (!m_ipc_server || port != m_old_port)
{
IPC.notice("Starting server with port %d", port);
m_ipc_server = std::make_unique<IPC_server>();
m_old_port = port;
}
}
else
else if (m_ipc_server)
{
IPC.notice("Stopping server");
m_ipc_server.reset();
}
}

View File

@ -9,6 +9,9 @@
#include "ipc_settings_dialog.h"
#include "Emu/IPC_config.h"
#include "Emu/IPC_socket.h"
#include "Emu/IdManager.h"
#include "Emu/System.h"
ipc_settings_dialog::ipc_settings_dialog(QWidget* parent)
: QDialog(parent)
@ -54,6 +57,15 @@ ipc_settings_dialog::ipc_settings_dialog(QWidget* parent)
g_cfg_ipc.set_port(server_port);
g_cfg_ipc.save();
if (auto manager = g_fxo->try_get<IPC_socket::IPC_server_manager>())
{
manager->set_server_enabled(server_enabled);
}
else if (server_enabled && Emu.IsRunning())
{
g_fxo->init<IPC_socket::IPC_server_manager>(true);
}
accept();
});