From 24a4bc98f969cddd55e3a7fda807aa67db4bbc4f Mon Sep 17 00:00:00 2001 From: Audric Date: Tue, 28 Apr 2026 20:25:31 +0200 Subject: [PATCH] feat(reflector): activate fanoutClient* across satellite+twin links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the no-op stubs from Task 4. Per-client liveness deltas (MsgPeerClient{Connected,Disconnected,Rx,Status}) now flow over satellite (parent->sat and sat->parent) and twin links. Trunk peers are intentionally skipped — see spec §3 for the routing rationale. Each receiving reflector republishes the events on its own MQTT broker as peer//client//, retained for rx and status, ephemeral for connect and disconnect. --- src/svxlink/reflector/Reflector.cpp | 75 +++++++++++++++++++++++++---- src/svxlink/reflector/Reflector.h | 1 - 2 files changed, 66 insertions(+), 10 deletions(-) diff --git a/src/svxlink/reflector/Reflector.cpp b/src/svxlink/reflector/Reflector.cpp index 0466258..eb86c28 100644 --- a/src/svxlink/reflector/Reflector.cpp +++ b/src/svxlink/reflector/Reflector.cpp @@ -3148,32 +3148,89 @@ void Reflector::fanoutClientConnected(const std::string& callsign, uint32_t tg, const std::string& ip) { - // Stub — real iteration over m_satellite_con_map / m_satellite_client / - // m_twin_link is added in Task 8 of the peer-client-liveness plan. - (void)callsign; (void)tg; (void)ip; + for (auto& kv : m_satellite_con_map) + { + if (kv.second != nullptr) + { + kv.second->sendClientConnected(callsign, tg, ip); + } + } + if (m_satellite_client != nullptr) + { + m_satellite_client->sendClientConnected(callsign, tg, ip); + } + if (m_twin_link != nullptr) + { + m_twin_link->sendClientConnected(callsign, tg, ip); + } } void Reflector::fanoutClientDisconnected(const std::string& callsign) { - // Stub — see Task 8. - (void)callsign; + for (auto& kv : m_satellite_con_map) + { + if (kv.second != nullptr) + { + kv.second->sendClientDisconnected(callsign); + } + } + if (m_satellite_client != nullptr) + { + m_satellite_client->sendClientDisconnected(callsign); + } + if (m_twin_link != nullptr) + { + m_twin_link->sendClientDisconnected(callsign); + } } void Reflector::fanoutClientRx(const std::string& callsign, const Json::Value& rx_json) { - // Stub — see Task 8. - (void)callsign; (void)rx_json; + Json::StreamWriterBuilder wb; + wb["indentation"] = ""; + std::string s = Json::writeString(wb, rx_json); + for (auto& kv : m_satellite_con_map) + { + if (kv.second != nullptr) + { + kv.second->sendClientRx(callsign, s); + } + } + if (m_satellite_client != nullptr) + { + m_satellite_client->sendClientRx(callsign, s); + } + if (m_twin_link != nullptr) + { + m_twin_link->sendClientRx(callsign, s); + } } void Reflector::fanoutClientStatus(const std::string& callsign, const Json::Value& status_json) { - // Stub — see Task 8. - (void)callsign; (void)status_json; + Json::StreamWriterBuilder wb; + wb["indentation"] = ""; + std::string s = Json::writeString(wb, status_json); + for (auto& kv : m_satellite_con_map) + { + if (kv.second != nullptr) + { + kv.second->sendClientStatus(callsign, s); + } + } + if (m_satellite_client != nullptr) + { + m_satellite_client->sendClientStatus(callsign, s); + } + if (m_twin_link != nullptr) + { + m_twin_link->sendClientStatus(callsign, s); + } } diff --git a/src/svxlink/reflector/Reflector.h b/src/svxlink/reflector/Reflector.h index b7a6893..e2c1e49 100644 --- a/src/svxlink/reflector/Reflector.h +++ b/src/svxlink/reflector/Reflector.h @@ -286,7 +286,6 @@ class Reflector : public sigc::trackable // Per-client liveness fanout to satellite and twin peers. Iterates // m_satellite_con_map, m_satellite_client, and m_twin_link. Trunk // peers are intentionally NOT fanned out (deferred per design spec). - // Bodies are stubs in this commit and become real iteration in Task 8. void fanoutClientConnected(const std::string& callsign, uint32_t tg, const std::string& ip); void fanoutClientDisconnected(const std::string& callsign);