feat(reflector): fanoutClient* stubs + hook into MQTT emit points
Adds the dispatch surface for per-client liveness deltas. The fanout methods are stubs in this commit — they will iterate satellite/twin links once those gain sendClient* methods (Tasks 5-7). Also wires the new local MQTT topic client/<call>/status (retained) into Reflector::publishClientStatus so dashboards get rich status as a per-client topic, not only via nodes/local.
This commit is contained in:
1 parent
e25ae9caa1
commit
37a6a11548
2 files changed
+62
-5
No files matched your search
@@ -1082,6 +1082,7 @@ void Reflector::clientDisconnected(Async::FramedTcpConnection *con,
|
||||
{
|
||||
m_mqtt->onClientDisconnected(client->callsign());
|
||||
}
|
||||
fanoutClientDisconnected(client->callsign());
|
||||
if (m_redis != nullptr)
|
||||
{
|
||||
m_redis->clearLiveClient(client->callsign());
|
||||
@@ -3115,23 +3116,66 @@ void Reflector::publishRxUpdate(ReflectorClient* client)
|
||||
{
|
||||
m_mqtt->onRxUpdate(client->callsign(), client->rxStatusJson());
|
||||
}
|
||||
fanoutClientRx(client->callsign(), client->rxStatusJson());
|
||||
publishClientStatus(client);
|
||||
} /* Reflector::publishRxUpdate */
|
||||
|
||||
|
||||
void Reflector::publishClientStatus(ReflectorClient* client)
|
||||
{
|
||||
if (m_redis == nullptr || client == nullptr) return;
|
||||
if (client == nullptr) return;
|
||||
const std::string& cs = client->callsign();
|
||||
if (cs.empty()) return;
|
||||
if (!m_status["nodes"].isMember(cs)) return;
|
||||
Json::StreamWriterBuilder wb;
|
||||
wb["indentation"] = "";
|
||||
m_redis->pushClientStatus(cs,
|
||||
Json::writeString(wb, m_status["nodes"][cs]));
|
||||
const Json::Value& status = m_status["nodes"][cs];
|
||||
|
||||
if (m_mqtt != nullptr)
|
||||
{
|
||||
m_mqtt->onClientStatus(cs, status);
|
||||
}
|
||||
if (m_redis != nullptr)
|
||||
{
|
||||
Json::StreamWriterBuilder wb;
|
||||
wb["indentation"] = "";
|
||||
m_redis->pushClientStatus(cs, Json::writeString(wb, status));
|
||||
}
|
||||
fanoutClientStatus(cs, status);
|
||||
} /* Reflector::publishClientStatus */
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
void Reflector::fanoutClientDisconnected(const std::string& callsign)
|
||||
{
|
||||
// Stub — see Task 8.
|
||||
(void)callsign;
|
||||
}
|
||||
|
||||
|
||||
void Reflector::fanoutClientRx(const std::string& callsign,
|
||||
const Json::Value& rx_json)
|
||||
{
|
||||
// Stub — see Task 8.
|
||||
(void)callsign; (void)rx_json;
|
||||
}
|
||||
|
||||
|
||||
void Reflector::fanoutClientStatus(const std::string& callsign,
|
||||
const Json::Value& status_json)
|
||||
{
|
||||
// Stub — see Task 8.
|
||||
(void)callsign; (void)status_json;
|
||||
}
|
||||
|
||||
|
||||
void Reflector::publishMetaToRedis(void)
|
||||
{
|
||||
if (m_redis == nullptr) return;
|
||||
@@ -3209,6 +3253,7 @@ void Reflector::onClientAuthenticated(const std::string& callsign,
|
||||
{
|
||||
m_mqtt->onClientConnected(callsign, tg, ip);
|
||||
}
|
||||
fanoutClientConnected(callsign, tg, ip);
|
||||
if (m_redis != nullptr)
|
||||
{
|
||||
m_redis->pushLiveClient(callsign, ip, "", tg);
|
||||
|
||||
@@ -281,6 +281,18 @@ class Reflector : public sigc::trackable
|
||||
// Push the rich per-client status blob (rx, monitoredTGs, qth, ...)
|
||||
// to Redis. Cheap no-op if Redis is not configured.
|
||||
void publishClientStatus(ReflectorClient* client);
|
||||
|
||||
// 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);
|
||||
void fanoutClientRx(const std::string& callsign,
|
||||
const Json::Value& rx_json);
|
||||
void fanoutClientStatus(const std::string& callsign,
|
||||
const Json::Value& status_json);
|
||||
// Reflector-wide live:meta hash (mode, version, prefixes, ports,
|
||||
// cluster TGs, satellite-server stats). Event-driven write.
|
||||
void publishMetaToRedis(void);
|
||||
|
||||
Reference in new issue
Block a user