mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
message parser
event handling is now "async" in it's own separate thread
This commit is contained in:
@@ -85,25 +85,25 @@ void event_handler(json event)
|
|||||||
case Event::clicked:
|
case Event::clicked:
|
||||||
{
|
{
|
||||||
spdlog::debug("Event {}: {}", type, std::string(event.at("id")));
|
spdlog::debug("Event {}: {}", type, std::string(event.at("id")));
|
||||||
g_simulators->invoke_active_simulator()->get_UI_item(std::string(event.at("id")))->click();
|
std::thread([id = std::string(event.at("id"))] { g_simulators->invoke_active_simulator()->get_UI_item(id)->click(); }).detach();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Event::value_changed:
|
case Event::value_changed:
|
||||||
{
|
{
|
||||||
spdlog::debug("Event {}: {} {}", type, std::string(event.at("id")), (double)(event["value"]));
|
spdlog::debug("Event {}: {} {}", type, std::string(event.at("id")), (double)(event["value"]));
|
||||||
g_simulators->invoke_active_simulator()->get_UI_item(std::string(event.at("id")))->set_value((double)event.at("value"));
|
std::thread([id = std::string(event.at("id")), value = (double)(event["value"])] { g_simulators->invoke_active_simulator()->get_UI_item(id)->set_value(value); }).detach();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Event::text_changed:
|
case Event::text_changed:
|
||||||
{
|
{
|
||||||
spdlog::debug("Event {}: {} {}", type, std::string(event.at("id")), std::string(event.at("text")));
|
spdlog::debug("Event {}: {} {}", type, std::string(event.at("id")), std::string(event.at("text")));
|
||||||
g_simulators->invoke_active_simulator()->get_UI_item(std::string(event.at("id")))->set_text(std::string(event.at("text")));
|
std::thread([id = std::string(event.at("id")), text = std::string(event.at("text"))] { g_simulators->invoke_active_simulator()->get_UI_item(id)->set_text(text); }).detach();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Event::selected:
|
case Event::selected:
|
||||||
{
|
{
|
||||||
spdlog::debug("Event {}: {} {}", type, std::string(event.at("id")), std::string(event.at("selected")));
|
spdlog::debug("Event {}: {} {}", type, std::string(event.at("id")), std::string(event.at("selected")));
|
||||||
g_simulators->invoke_active_simulator()->get_UI_item(std::string(event.at("id")))->set_selected(std::string(event.at("selected")));
|
std::thread([id = std::string(event.at("id")), selected = std::string(event.at("selected"))]{ g_simulators->invoke_active_simulator()->get_UI_item(id)->set_selected(selected); }).detach();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user