TwinLink: mirror external trunk-talker state to partner
When TrunkLink receives MsgTrunkTalkerStart/Stop from an external peer, Reflector now forwards those events to TwinLink via notifyExternalTrunkTalkerStart/Stop. TwinLink sends MsgTwinExtTalkerStart (type 123) / MsgTwinExtTalkerStop (type 124) over the twin link, and the receiving side calls TGHandler::setTrunkTalkerForTGViaPeer so the partner twin blocks local clients from keying up the TG. On disconnect, clearPeerTalkerState iterates held TGs before clearing them so the partner is also notified. No echo loop: Reflector::onTrunkTalkerUpdated does not feed back into TwinLink.
This commit is contained in:
1 parent
2554efb392
commit
6fb5aa4b91
4 files changed
+54
-11
No files matched your search
@@ -2979,6 +2979,20 @@ void Reflector::onClientAuthenticated(const std::string& callsign,
|
|||||||
} /* Reflector::onClientAuthenticated */
|
} /* Reflector::onClientAuthenticated */
|
||||||
|
|
||||||
|
|
||||||
|
void Reflector::notifyExternalTrunkTalkerStart(uint32_t tg,
|
||||||
|
const std::string& peer_id, const std::string& callsign)
|
||||||
|
{
|
||||||
|
if (m_twin_link) m_twin_link->onExternalTrunkTalkerStart(tg, peer_id, callsign);
|
||||||
|
} /* Reflector::notifyExternalTrunkTalkerStart */
|
||||||
|
|
||||||
|
|
||||||
|
void Reflector::notifyExternalTrunkTalkerStop(uint32_t tg,
|
||||||
|
const std::string& peer_id)
|
||||||
|
{
|
||||||
|
if (m_twin_link) m_twin_link->onExternalTrunkTalkerStop(tg, peer_id);
|
||||||
|
} /* Reflector::notifyExternalTrunkTalkerStop */
|
||||||
|
|
||||||
|
|
||||||
void Reflector::scheduleNodeListUpdate(void)
|
void Reflector::scheduleNodeListUpdate(void)
|
||||||
{
|
{
|
||||||
// Debounce — multiple rapid login/TG-change events coalesce into one send
|
// Debounce — multiple rapid login/TG-change events coalesce into one send
|
||||||
|
|||||||
@@ -262,6 +262,11 @@ class Reflector : public sigc::trackable
|
|||||||
void publishRxUpdate(ReflectorClient* client);
|
void publishRxUpdate(ReflectorClient* client);
|
||||||
void onClientAuthenticated(const std::string& callsign, uint32_t tg,
|
void onClientAuthenticated(const std::string& callsign, uint32_t tg,
|
||||||
const std::string& ip);
|
const std::string& ip);
|
||||||
|
void notifyExternalTrunkTalkerStart(uint32_t tg,
|
||||||
|
const std::string& peer_id,
|
||||||
|
const std::string& callsign);
|
||||||
|
void notifyExternalTrunkTalkerStop(uint32_t tg,
|
||||||
|
const std::string& peer_id);
|
||||||
void onTrunkStateChanged(const std::string& section,
|
void onTrunkStateChanged(const std::string& section,
|
||||||
const std::string& peer_id,
|
const std::string& peer_id,
|
||||||
const std::string& direction, bool up,
|
const std::string& direction, bool up,
|
||||||
|
|||||||
@@ -832,6 +832,7 @@ void TrunkLink::handleMsgTrunkTalkerStart(std::istream& is)
|
|||||||
m_peer_active_tgs.insert(local_tg);
|
m_peer_active_tgs.insert(local_tg);
|
||||||
m_peer_interested_tgs[local_tg] = std::time(nullptr);
|
m_peer_interested_tgs[local_tg] = std::time(nullptr);
|
||||||
TGHandler::instance()->setTrunkTalkerForTG(local_tg, msg.callsign());
|
TGHandler::instance()->setTrunkTalkerForTG(local_tg, msg.callsign());
|
||||||
|
m_reflector->notifyExternalTrunkTalkerStart(local_tg, m_section, msg.callsign());
|
||||||
} /* TrunkLink::handleMsgTrunkTalkerStart */
|
} /* TrunkLink::handleMsgTrunkTalkerStart */
|
||||||
|
|
||||||
|
|
||||||
@@ -860,6 +861,7 @@ void TrunkLink::handleMsgTrunkTalkerStop(std::istream& is)
|
|||||||
m_yielded_tgs.erase(local_tg);
|
m_yielded_tgs.erase(local_tg);
|
||||||
m_peer_active_tgs.erase(local_tg);
|
m_peer_active_tgs.erase(local_tg);
|
||||||
TGHandler::instance()->clearTrunkTalkerForTG(local_tg);
|
TGHandler::instance()->clearTrunkTalkerForTG(local_tg);
|
||||||
|
m_reflector->notifyExternalTrunkTalkerStop(local_tg, m_section);
|
||||||
} /* TrunkLink::handleMsgTrunkTalkerStop */
|
} /* TrunkLink::handleMsgTrunkTalkerStop */
|
||||||
|
|
||||||
|
|
||||||
@@ -1093,6 +1095,7 @@ void TrunkLink::clearPeerTalkerState(void)
|
|||||||
for (uint32_t tg : m_peer_active_tgs)
|
for (uint32_t tg : m_peer_active_tgs)
|
||||||
{
|
{
|
||||||
TGHandler::instance()->clearTrunkTalkerForTG(tg);
|
TGHandler::instance()->clearTrunkTalkerForTG(tg);
|
||||||
|
m_reflector->notifyExternalTrunkTalkerStop(tg, m_section);
|
||||||
}
|
}
|
||||||
m_peer_active_tgs.clear();
|
m_peer_active_tgs.clear();
|
||||||
m_yielded_tgs.clear();
|
m_yielded_tgs.clear();
|
||||||
|
|||||||
@@ -224,18 +224,20 @@ void TwinLink::onLocalFlush(uint32_t tg)
|
|||||||
} /* TwinLink::onLocalFlush */
|
} /* TwinLink::onLocalFlush */
|
||||||
|
|
||||||
|
|
||||||
void TwinLink::onExternalTrunkTalkerStart(uint32_t /*tg*/,
|
void TwinLink::onExternalTrunkTalkerStart(uint32_t tg,
|
||||||
const std::string& /*peer_id*/,
|
const std::string& peer_id,
|
||||||
const std::string& /*callsign*/)
|
const std::string& callsign)
|
||||||
{
|
{
|
||||||
// Phase C2
|
if (!isActive()) return;
|
||||||
|
sendMsg(MsgTwinExtTalkerStart(tg, peer_id, callsign));
|
||||||
} /* TwinLink::onExternalTrunkTalkerStart */
|
} /* TwinLink::onExternalTrunkTalkerStart */
|
||||||
|
|
||||||
|
|
||||||
void TwinLink::onExternalTrunkTalkerStop(uint32_t /*tg*/,
|
void TwinLink::onExternalTrunkTalkerStop(uint32_t tg,
|
||||||
const std::string& /*peer_id*/)
|
const std::string& peer_id)
|
||||||
{
|
{
|
||||||
// Phase C2
|
if (!isActive()) return;
|
||||||
|
sendMsg(MsgTwinExtTalkerStop(tg, peer_id));
|
||||||
} /* TwinLink::onExternalTrunkTalkerStop */
|
} /* TwinLink::onExternalTrunkTalkerStop */
|
||||||
|
|
||||||
|
|
||||||
@@ -470,15 +472,34 @@ void TwinLink::handleMsgTrunkHeartbeat(void)
|
|||||||
} /* TwinLink::handleMsgTrunkHeartbeat */
|
} /* TwinLink::handleMsgTrunkHeartbeat */
|
||||||
|
|
||||||
|
|
||||||
void TwinLink::handleMsgTwinExtTalkerStart(std::istream& /*is*/)
|
void TwinLink::handleMsgTwinExtTalkerStart(std::istream& is)
|
||||||
{
|
{
|
||||||
// Phase C2
|
MsgTwinExtTalkerStart msg;
|
||||||
|
if (!msg.unpack(is))
|
||||||
|
{
|
||||||
|
cerr << "*** ERROR[TWIN]: Failed to unpack MsgTwinExtTalkerStart" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// setTrunkTalkerForTGViaPeer records peer attribution and fires
|
||||||
|
// trunkTalkerUpdated → Reflector::onTrunkTalkerUpdated, which broadcasts
|
||||||
|
// MsgTalkerStart to local clients. That handler does NOT call back into
|
||||||
|
// TwinLink, so there is no echo loop.
|
||||||
|
TGHandler::instance()->setTrunkTalkerForTGViaPeer(
|
||||||
|
msg.tg(), msg.callsign(), msg.peerId());
|
||||||
} /* TwinLink::handleMsgTwinExtTalkerStart */
|
} /* TwinLink::handleMsgTwinExtTalkerStart */
|
||||||
|
|
||||||
|
|
||||||
void TwinLink::handleMsgTwinExtTalkerStop(std::istream& /*is*/)
|
void TwinLink::handleMsgTwinExtTalkerStop(std::istream& is)
|
||||||
{
|
{
|
||||||
// Phase C2
|
MsgTwinExtTalkerStop msg;
|
||||||
|
if (!msg.unpack(is)) return;
|
||||||
|
// Only clear if this peer still holds the TG — avoids racing a newer talker
|
||||||
|
// that took over after the stop was queued on the wire.
|
||||||
|
if (TGHandler::instance()->peerIdForTG(msg.tg()) == msg.peerId())
|
||||||
|
{
|
||||||
|
TGHandler::instance()->setTrunkTalkerForTGViaPeer(
|
||||||
|
msg.tg(), "", msg.peerId());
|
||||||
|
}
|
||||||
} /* TwinLink::handleMsgTwinExtTalkerStop */
|
} /* TwinLink::handleMsgTwinExtTalkerStop */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user