mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
b message parser
add try catch around command_parser and event_parser
This commit is contained in:
@@ -23,10 +23,12 @@ std::string message_parser(std::string message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
json command_parser(json command)
|
json command_parser(json command)
|
||||||
|
{
|
||||||
|
json j;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
std::string type = command["type"];
|
std::string type = command["type"];
|
||||||
Command cmd = magic_enum::enum_cast<Command>(type).value_or(Command::end);
|
Command cmd = magic_enum::enum_cast<Command>(type).value_or(Command::end);
|
||||||
json j;
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case Command::get_UI_element:
|
case Command::get_UI_element:
|
||||||
@@ -57,10 +59,18 @@ json command_parser(json command)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(const json::exception& e)
|
||||||
|
{
|
||||||
|
spdlog::error(e.what());
|
||||||
|
}
|
||||||
|
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_handler(json event)
|
void event_handler(json event)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
std::string type = event["type"];
|
std::string type = event["type"];
|
||||||
Event e = magic_enum::enum_cast<Event>(type).value_or(Event::end);
|
Event e = magic_enum::enum_cast<Event>(type).value_or(Event::end);
|
||||||
@@ -102,3 +112,8 @@ void event_handler(json event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(const json::exception& e)
|
||||||
|
{
|
||||||
|
spdlog::error(e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user