Files
MuditaOS/module-services/service-desktop/parser/MessageHandler.hpp
Artur Śleszyński b15006a94c [CP-564] Make desktop endpoints a separate lib
In order to have different sets of endpoints for different products,
we need to separate endpoints from the desktop service.
2021-09-21 10:41:37 +02:00

41 lines
1.1 KiB
C++

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
#include <Service/Service.hpp>
#include <json11.hpp>
namespace sdesktop::endpoints
{
class EndpointFactory;
class MessageHandler
{
json11::Json messageJson;
std::string JsonErrorMsg;
sys::Service *OwnerServicePtr = nullptr;
std::unique_ptr<EndpointFactory> endpointFactory;
public:
MessageHandler(sys::Service *OwnerService, std::unique_ptr<EndpointFactory> endpointFactory);
[[nodiscard]] auto isJSONNull() const -> bool
{
return messageJson.is_null();
};
[[nodiscard]] auto isValid() const noexcept -> bool
{
return JsonErrorMsg.empty();
}
[[nodiscard]] auto getErrorString() const -> const std::string &
{
return JsonErrorMsg;
};
void parseMessage(const std::string &msg);
void processMessage();
};
} // namespace sdesktop::endpoints