Bootstrap

sdbusplus:监听属性的变化

sdbusplus如果想监听service属性的变化,不需要在service侧做什么,只需要在client注册想要监听的接口即可,当属性变化时,会发送signal,可以通过该signal获得变化的属性及其新值:


//recv_prop_signal.cpp
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
#include <sdbusplus/bus.hpp>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
namespace rules = sdbusplus::bus::match::rules;
using propertyVariantType = std::variant<string, int>;
using propertyChangesType = std::map<std::string, propertyVariantType>;
auto recvCalculatPropSignal(sdbusplus::asio::connection &bus)
{
    auto propertyMatch = std::make_shared<sdbusplus::bus::match_t>(bus, 
        rules::propertiesChangedNamespace("/calculate_obj", "calculate_infterface.data"),
        [](sdbusplus::message::message& msg) {
            strin
;