Add API to set signal destination (#168)

With this patch it is possible to create unicast signals.
This commit is contained in:
Marek Blaha
2021-04-29 17:18:04 +02:00
committed by GitHub
parent d46cbba23c
commit 5ee4c61a1b
2 changed files with 7 additions and 0 deletions

View File

@ -215,6 +215,7 @@ namespace sdbus {
public:
Signal() = default;
void setDestination(const std::string& destination);
void send() const;
};

View File

@ -818,6 +818,12 @@ void Signal::send() const
SDBUS_THROW_ERROR_IF(r < 0, "Failed to emit signal", -r);
}
void Signal::setDestination(const std::string& destination)
{
auto r = sd_bus_message_set_destination((sd_bus_message*)msg_, destination.c_str());
SDBUS_THROW_ERROR_IF(r < 0, "Failed to set signal destination", -r);
}
PlainMessage createPlainMessage()
{
static auto connection = internal::createConnection();