基于前面对于sdbusplus的使用,可以看出,使用sdbusplus时可以通过bus完成method的调用,也可以通过connection完成方法的调用,比如:
auto b = bus::new_default_user();
b.new_method_call(...);
boost::asio::io_context io;
auto conn = make_shared<sdbusplus::asio::connection>(io);
auto methodCall = conn->new_method_call(...);
而实际上connection是继承于bus
//connection.hpp
class connection : public sdbusplus::bus_t
{
public:
// default to system bus
connection(boost::asio::io_context& io) :
sdbusplus::bus_t(sdbusplus::bus::new_default()), io_(io),
socket(io_.get_executor(), get_fd())
{
read_immediate();
}
conne