diff --git a/src/TopologyManager.cc b/src/TopologyManager.cc index 57c21d1..e04e5eb 100644 --- a/src/TopologyManager.cc +++ b/src/TopologyManager.cc @@ -59,14 +59,6 @@ TopologyManager::TopologyManager(std::string_view announcePath, std::string_view oss << '\0' << std::hex << std::setw(16) << std::setfill('0') << mNodeId; mAddress = oss.str(); - TopologyMessage msg; - auto nodeMsg = msg.mutable_node_changes()->Add(); - nodeMsg->set_id(mNodeId); - nodeMsg->set_op(NodeOperation::JOIN); - nodeMsg->set_name(mName); - nodeMsg->set_address(oss.str()); - mStore->ApplyUpdate(msg); - mMainThread = std::thread([this]() { MainLoop(); }); } @@ -102,6 +94,18 @@ void TopologyManager::MainLoop() { } }; + { + // send update about ourself + TopologyMessage msg; + auto nodeMsg = msg.mutable_node_changes()->Add(); + nodeMsg->set_id(mNodeId); + nodeMsg->set_op(NodeOperation::JOIN); + nodeMsg->set_name(mName); + nodeMsg->set_address(mAddress); + mStore->ApplyUpdate(msg); + mOnJoin(*nodeMsg); + } + while (!mShutdown) { mClient = UDSClient::Create(mAnnouncePath, onMessage); if (mClient != nullptr) {