// // Created by stephane bourque on 2022-05-05. // #pragma once #include "framework/RESTAPI_utils.h" #include "framework/utils.h" namespace OpenWifi { template struct WebSocketNotification { inline static uint64_t xid = 1; uint64_t notification_id = ++xid; // std::string type; std::uint64_t type_id=0; ContentStruct content; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); }; template void WebSocketNotification::to_json(Poco::JSON::Object &Obj) const { RESTAPI_utils::field_to_json(Obj, "notification_id", notification_id); // RESTAPI_utils::field_to_json(Obj, "type", type); RESTAPI_utils::field_to_json(Obj, "type_id", type_id); RESTAPI_utils::field_to_json(Obj, "content", content); } template bool WebSocketNotification::from_json(const Poco::JSON::Object::Ptr &Obj) { try { RESTAPI_utils::field_from_json(Obj, "notification_id", notification_id); // RESTAPI_utils::field_from_json(Obj, "type", type); RESTAPI_utils::field_from_json(Obj, "type_id", type_id); RESTAPI_utils::field_from_json(Obj, "content", content); return true; } catch (...) { } return false; } }