Skip to content

Commit

Permalink
Check if service is already advertised
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina committed Feb 11, 2021
1 parent 6bbd564 commit 8a3734f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/gui/GuiRunner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,16 @@ void GuiRunner::RequestState()
}
reqSrv = reqSrvValid;

this->node.Advertise(reqSrv, &GuiRunner::OnStateAsyncService, this);
auto advertised = this->node.AdvertisedServices();
if (std::find(advertised.begin(), advertised.end(), reqSrv) ==
advertised.end())
{
if (!this->node.Advertise(reqSrv, &GuiRunner::OnStateAsyncService, this))
{
ignerr << "Failed to advertise [" << reqSrv << "]" << std::endl;
}
}

ignition::msgs::StringMsg req;
req.set_data(reqSrv);

Expand All @@ -98,7 +107,7 @@ void GuiRunner::OnPluginAdded(const QString &_objectName)
return;
}

RequestState();
this->RequestState();
}

/////////////////////////////////////////////////
Expand Down

0 comments on commit 8a3734f

Please sign in to comment.