mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
b message parser
add try catch around command_parser and event_parser
This commit is contained in:
@@ -24,9 +24,11 @@ std::string message_parser(std::string message)
|
||||
|
||||
json command_parser(json command)
|
||||
{
|
||||
json j;
|
||||
try
|
||||
{
|
||||
std::string type = command["type"];
|
||||
Command cmd = magic_enum::enum_cast<Command>(type).value_or(Command::end);
|
||||
json j;
|
||||
switch (cmd)
|
||||
{
|
||||
case Command::get_UI_element:
|
||||
@@ -57,11 +59,19 @@ json command_parser(json command)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(const json::exception& e)
|
||||
{
|
||||
spdlog::error(e.what());
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
void event_handler(json event)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string type = event["type"];
|
||||
Event e = magic_enum::enum_cast<Event>(type).value_or(Event::end);
|
||||
if (g_simulators->invoke_active_simulator() == nullptr)
|
||||
@@ -101,4 +111,9 @@ void event_handler(json event)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const json::exception& e)
|
||||
{
|
||||
spdlog::error(e.what());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user