mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
message parser
add cmd name to response
This commit is contained in:
@@ -30,27 +30,36 @@ json command_parser(json command)
|
|||||||
case Command::get_UI_element:
|
case Command::get_UI_element:
|
||||||
{
|
{
|
||||||
std::string id = command["id"];
|
std::string id = command["id"];
|
||||||
return g_simulators.invoke_active_simulator()->get_UI_item(id)->to_json();
|
json j;
|
||||||
|
j["response"] = "get_UI_element";
|
||||||
|
j["UI_item"] = g_simulators.invoke_active_simulator()->get_UI_item(id)->to_json();
|
||||||
|
return j;
|
||||||
}
|
}
|
||||||
case Command::get_UI_elements:
|
case Command::get_UI_elements:
|
||||||
{
|
{
|
||||||
return g_simulators.invoke_active_simulator()->get_UI_items();
|
json j;
|
||||||
|
j["response"] = "get_UI_elements";
|
||||||
|
j["UI_items"] = g_simulators.invoke_active_simulator()->get_UI_items()["UI_items"];
|
||||||
|
return j;
|
||||||
}
|
}
|
||||||
case Command::switch_simulator:
|
case Command::switch_simulator:
|
||||||
{
|
{
|
||||||
std::string name = command["name"];
|
g_simulators.switch_simulator(command["name"]);
|
||||||
g_simulators.switch_simulator(name);
|
json j;
|
||||||
return "";
|
j["response"] = "switch_simulator";
|
||||||
|
return j;
|
||||||
}
|
}
|
||||||
case Command::get_active_simulator_name:
|
case Command::get_active_simulator_name:
|
||||||
{
|
{
|
||||||
json j;
|
json j;
|
||||||
|
j["response"] = "get_active_simulator_name";
|
||||||
j["name"] = g_simulators.active_simulator_name();
|
j["name"] = g_simulators.active_simulator_name();
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
case Command::get_simulators:
|
case Command::get_simulators:
|
||||||
{
|
{
|
||||||
json j;
|
json j;
|
||||||
|
j["response"] = "get_simulators";
|
||||||
j["simulators"] = g_simulators.list_simulators();
|
j["simulators"] = g_simulators.list_simulators();
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user