twin: fan twin partner roster into MQTT and Redis
Route the twin-received MsgTrunkNodeList through Reflector::onPeerNodeList() — the same fan-out TrunkLink uses — so MQTT publishes nodes/<peer_id> and Redis pushPeerNode entries also cover the twin partner, not just trunk peers. Before this, /status exposed twin.nodes but MQTT/Redis did not; consumers reading only from Redis or MQTT missed the roster of the twin partner entirely. On twin link-down, clearPartnerRosterIfInactive() pushes an empty list so onPeerNodeList's tombstone path clears Redis / empties the MQTT topic — matching the cleanup we do for a trunk peer that goes down.
This commit is contained in:
1 parent
fa6f137e1c
commit
cadc5c5aa2
2 files changed
+26
No files matched your search
@@ -392,6 +392,8 @@ void TwinLink::onDisconnected(TcpConnection* /*con*/,
|
|||||||
m_heartbeat_timer.setEnable(false);
|
m_heartbeat_timer.setEnable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearPartnerRosterIfInactive();
|
||||||
|
|
||||||
// TcpPrioClient auto-reconnects — nothing else to do
|
// TcpPrioClient auto-reconnects — nothing else to do
|
||||||
} /* TwinLink::onDisconnected */
|
} /* TwinLink::onDisconnected */
|
||||||
|
|
||||||
@@ -652,10 +654,26 @@ void TwinLink::handleMsgTrunkNodeList(std::istream& is)
|
|||||||
" node list entrie(s) with empty/invalid callsign");
|
" node list entrie(s) with empty/invalid callsign");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fan out to MQTT / Redis via the same path TrunkLink uses, keyed on
|
||||||
|
// the twin's peer_id. Keeps /status, MQTT and Redis consistent.
|
||||||
|
m_reflector->onPeerNodeList(peerId(), sanitized);
|
||||||
m_partner_nodes = std::move(sanitized);
|
m_partner_nodes = std::move(sanitized);
|
||||||
} /* TwinLink::handleMsgTrunkNodeList */
|
} /* TwinLink::handleMsgTrunkNodeList */
|
||||||
|
|
||||||
|
|
||||||
|
void TwinLink::clearPartnerRosterIfInactive(void)
|
||||||
|
{
|
||||||
|
if (isActive()) return;
|
||||||
|
if (m_partner_nodes.empty()) return;
|
||||||
|
m_partner_nodes.clear();
|
||||||
|
// Empty roster drives onPeerNodeList's tombstone cleanup — it will
|
||||||
|
// clearPeerNode each callsign previously cached under peerId() in
|
||||||
|
// Redis and publish an empty list to MQTT.
|
||||||
|
m_reflector->onPeerNodeList(peerId(),
|
||||||
|
std::vector<MsgTrunkNodeList::NodeEntry>{});
|
||||||
|
} /* TwinLink::clearPartnerRosterIfInactive */
|
||||||
|
|
||||||
|
|
||||||
void TwinLink::heartbeatTick(Async::Timer* /*t*/)
|
void TwinLink::heartbeatTick(Async::Timer* /*t*/)
|
||||||
{
|
{
|
||||||
// Outbound heartbeat
|
// Outbound heartbeat
|
||||||
@@ -697,6 +715,8 @@ void TwinLink::heartbeatTick(Async::Timer* /*t*/)
|
|||||||
{
|
{
|
||||||
m_heartbeat_timer.setEnable(false);
|
m_heartbeat_timer.setEnable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearPartnerRosterIfInactive();
|
||||||
} /* TwinLink::heartbeatTick */
|
} /* TwinLink::heartbeatTick */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,11 @@ class TwinLink
|
|||||||
uint16_t partnerPort(void) const { return m_peer_port; }
|
uint16_t partnerPort(void) const { return m_peer_port; }
|
||||||
const std::string& secret(void) const { return m_secret; }
|
const std::string& secret(void) const { return m_secret; }
|
||||||
const std::string& localPrefix(void) const { return m_local_prefix; }
|
const std::string& localPrefix(void) const { return m_local_prefix; }
|
||||||
|
const std::string& peerId(void) const
|
||||||
|
{
|
||||||
|
return m_peer_id_received.empty() ? m_peer_id_config
|
||||||
|
: m_peer_id_received;
|
||||||
|
}
|
||||||
|
|
||||||
Json::Value statusJson(void) const;
|
Json::Value statusJson(void) const;
|
||||||
|
|
||||||
@@ -158,6 +163,7 @@ class TwinLink
|
|||||||
void handleMsgTrunkFlush(std::istream& is);
|
void handleMsgTrunkFlush(std::istream& is);
|
||||||
void handleMsgTrunkHeartbeat(void);
|
void handleMsgTrunkHeartbeat(void);
|
||||||
void handleMsgTrunkNodeList(std::istream& is);
|
void handleMsgTrunkNodeList(std::istream& is);
|
||||||
|
void clearPartnerRosterIfInactive(void);
|
||||||
void handleMsgTwinExtTalkerStart(std::istream& is);
|
void handleMsgTwinExtTalkerStart(std::istream& is);
|
||||||
void handleMsgTwinExtTalkerStop(std::istream& is);
|
void handleMsgTwinExtTalkerStop(std::istream& is);
|
||||||
void heartbeatTick(Async::Timer*);
|
void heartbeatTick(Async::Timer*);
|
||||||
|
|||||||
Reference in new issue
Block a user