Add a method to retrieve the unique name of a connection

This commit is contained in:
Bruno Marchand
2019-11-08 08:21:03 -05:00
committed by Stanislav Angelovič
parent d50a15b2a2
commit 5fe0f503ca
6 changed files with 24 additions and 0 deletions

View File

@@ -76,6 +76,14 @@ void Connection::releaseName(const std::string& name)
SDBUS_THROW_ERROR_IF(r < 0, "Failed to release bus name", -r);
}
std::string Connection::getUniqueName()
{
const char* unique = nullptr;
auto r = iface_->sd_bus_get_unique_name(bus_.get(), &unique);
SDBUS_THROW_ERROR_IF(r < 0 || unique == nullptr, "Failed to get unique bus name", -r);
return unique;
}
void Connection::enterProcessingLoop()
{
while (true)