twin: expose partner roster in /status (fixes #3)

Reflector::refreshStatus() now emits a m_status["twin"] object
(host, port, connection/hello state, prefix, peer_id, priorities)
mirroring the existing trunks[] pattern.

To populate the partner's connected-stations list, TwinLink now
carries MsgTrunkNodeList (type 121) over the [TWIN] socket —
reusing the trunk wire message, no new protocol type. Local
roster changes flow via Reflector::sendNodeListToAllPeers() ->
TwinLink::onLocalNodeListUpdated(); incoming lists are sanitized
and cached in m_partner_nodes, surfaced as twin.nodes.

Without this, [TWIN]-paired reflectors could not observe each
other's rosters from /status — the data was not on the wire at
all (TwinLink only carried talker state).
This commit is contained in:
Audric committed 2026-04-18 23:33:57 +02:00
1 parent 4bbd53172a
commit fa6f137e1c
4 files changed
+214 -2

No files matched your search

+20 -2
View File
@@ -43,6 +43,8 @@ logic — the pair shares everything.
#include <cstdint>
#include <vector>
#include <json/json.h>
/****************************************************************************
*
@@ -56,6 +58,15 @@ logic — the pair shares everything.
#include <AsyncTimer.h>
/****************************************************************************
*
* Local Includes
*
****************************************************************************/
#include "ReflectorMsg.h"
/****************************************************************************
*
* Forward declarations
@@ -63,8 +74,6 @@ logic — the pair shares everything.
****************************************************************************/
class Reflector;
class MsgTrunkHello;
class ReflectorMsg;
class TwinLink
{
@@ -92,12 +101,19 @@ class TwinLink
void onExternalTrunkTalkerStop(uint32_t tg,
const std::string& peer_id);
// Called by Reflector when the local node roster changes, to mirror
// our connected-stations list to the twin partner.
void onLocalNodeListUpdated(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes);
bool isActive(void) const;
const std::string& partnerHost(void) const { return m_peer_host; }
uint16_t partnerPort(void) const { return m_peer_port; }
const std::string& secret(void) const { return m_secret; }
const std::string& localPrefix(void) const { return m_local_prefix; }
Json::Value statusJson(void) const;
private:
using FramedTcpClient =
Async::TcpPrioClient<Async::FramedTcpConnection>;
@@ -124,6 +140,7 @@ class TwinLink
bool m_ib_hello_received;
unsigned m_ib_hb_tx_cnt;
unsigned m_ib_hb_rx_cnt;
std::vector<MsgTrunkNodeList::NodeEntry> m_partner_nodes;
// No copy
TwinLink(const TwinLink&);
@@ -140,6 +157,7 @@ class TwinLink
void handleMsgTrunkAudio(std::istream& is);
void handleMsgTrunkFlush(std::istream& is);
void handleMsgTrunkHeartbeat(void);
void handleMsgTrunkNodeList(std::istream& is);
void handleMsgTwinExtTalkerStart(std::istream& is);
void handleMsgTwinExtTalkerStop(std::istream& is);
void heartbeatTick(Async::Timer*);