diff --git a/src/svxlink/reflector/Reflector.cpp b/src/svxlink/reflector/Reflector.cpp index eb86c28..6bca9f2 100644 --- a/src/svxlink/reflector/Reflector.cpp +++ b/src/svxlink/reflector/Reflector.cpp @@ -3144,6 +3144,20 @@ void Reflector::publishClientStatus(ReflectorClient* client) } /* Reflector::publishClientStatus */ +uint32_t Reflector::currentClientTg(const std::string& callsign) const +{ + for (const auto& it : m_client_con_map) + { + ReflectorClient* c = it.second; + if (c != nullptr && c->callsign() == callsign) + { + return c->currentTG(); + } + } + return 0; +} /* Reflector::currentClientTg */ + + void Reflector::fanoutClientConnected(const std::string& callsign, uint32_t tg, const std::string& ip) @@ -3168,9 +3182,11 @@ void Reflector::fanoutClientConnected(const std::string& callsign, void Reflector::fanoutClientDisconnected(const std::string& callsign) { + uint32_t tg = currentClientTg(callsign); for (auto& kv : m_satellite_con_map) { - if (kv.second != nullptr) + if (kv.second != nullptr && + (tg == 0 || kv.second->filterPassesTg(tg))) { kv.second->sendClientDisconnected(callsign); } @@ -3192,9 +3208,11 @@ void Reflector::fanoutClientRx(const std::string& callsign, Json::StreamWriterBuilder wb; wb["indentation"] = ""; std::string s = Json::writeString(wb, rx_json); + uint32_t tg = currentClientTg(callsign); for (auto& kv : m_satellite_con_map) { - if (kv.second != nullptr) + if (kv.second != nullptr && + (tg == 0 || kv.second->filterPassesTg(tg))) { kv.second->sendClientRx(callsign, s); } @@ -3216,9 +3234,11 @@ void Reflector::fanoutClientStatus(const std::string& callsign, Json::StreamWriterBuilder wb; wb["indentation"] = ""; std::string s = Json::writeString(wb, status_json); + uint32_t tg = currentClientTg(callsign); for (auto& kv : m_satellite_con_map) { - if (kv.second != nullptr) + if (kv.second != nullptr && + (tg == 0 || kv.second->filterPassesTg(tg))) { kv.second->sendClientStatus(callsign, s); } diff --git a/src/svxlink/reflector/Reflector.h b/src/svxlink/reflector/Reflector.h index e2c1e49..cfd2994 100644 --- a/src/svxlink/reflector/Reflector.h +++ b/src/svxlink/reflector/Reflector.h @@ -283,6 +283,11 @@ class Reflector : public sigc::trackable // to Redis. Cheap no-op if Redis is not configured. void publishClientStatus(ReflectorClient* client); + // Look up a local client's current talk group by callsign. Returns 0 + // if the client is unknown. Used by fanoutClient{Disconnected,Rx,Status} + // to apply per-peer TG filter for events that don't carry an inline TG. + uint32_t currentClientTg(const std::string& callsign) const; + // 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). diff --git a/src/svxlink/reflector/SatelliteLink.h b/src/svxlink/reflector/SatelliteLink.h index 42a21bc..eba8ad5 100644 --- a/src/svxlink/reflector/SatelliteLink.h +++ b/src/svxlink/reflector/SatelliteLink.h @@ -80,6 +80,11 @@ class SatelliteLink : public sigc::trackable return m_partner_nodes; } + // Returns true if the given TG passes this satellite's filter (or if no + // filter is set). Used by Reflector::fanoutClient{Disconnected,Rx,Status} + // which lack an inline TG and must look it up externally. + bool filterPassesTg(uint32_t tg) const; + private: static const unsigned HEARTBEAT_TX_CNT_RESET = 10; static const unsigned HEARTBEAT_RX_CNT_RESET = 15; @@ -115,7 +120,6 @@ class SatelliteLink : public sigc::trackable void handleMsgPeerClientDisconnected(std::istream& is); void handleMsgPeerClientRx(std::istream& is); void handleMsgPeerClientStatus(std::istream& is); - bool filterPassesTg(uint32_t tg) const; void sendMsg(const ReflectorMsg& msg); void heartbeatTick(Async::Timer* t); };