TwinLink: outbound connect, handshake, heartbeat skeleton

Implements TwinLink.cpp with constructor (random priority nonce via
std::random_device, signal wiring), initialize() (parse [TWIN] HOST/PORT/
SECRET and [GLOBAL] LOCAL_PREFIX, addStaticSRVRecord + reconnect policy,
m_con.connect()), onConnected() sending MsgTrunkHello with ROLE_TWIN,
handleMsgTrunkHello() validating role/HMAC/prefix-match, heartbeatTick()
(2s TX / 5s RX thresholds), sendMsg/sendMsgOnOutbound/sendMsgOnInbound,
and acceptInboundConnection().  Phase C handlers (talker mirror, audio,
ext-trunk) are present as empty stubs.

Wires Reflector::initTwinLink() to construct and initialize a real TwinLink
(replaces stub), adds destructor cleanup, and adds TwinLink.cpp to
CMakeLists sources.  Build passes clean.
This commit is contained in:
Audric committed 2026-04-15 20:33:54 +02:00
1 parent 074b1aea4c
commit 9f349fff5c
3 files changed
+550 -3

No files matched your search

+11 -3
View File
@@ -70,6 +70,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "ReflectorClient.h"
#include "TGHandler.h"
#include "TrunkLink.h"
#include "TwinLink.h"
#include "RedisStore.h"
#include <version/SVXREFLECTOR.h>
@@ -324,6 +325,8 @@ Reflector::~Reflector(void)
m_sat_srv = nullptr;
delete m_satellite_client;
m_satellite_client = nullptr;
delete m_twin_link;
m_twin_link = nullptr;
m_client_con_map.clear();
ReflectorClient::cleanup();
delete TGHandler::instance();
@@ -3889,9 +3892,14 @@ void Reflector::initTwinLink(void)
{
return;
}
std::cout << "TWIN: section present in config (parser stub, no link yet)"
<< std::endl;
// Actual TwinLink creation lands in Task B2.
m_twin_link = new TwinLink(this, *m_cfg);
if (!m_twin_link->initialize())
{
delete m_twin_link;
m_twin_link = nullptr;
cerr << "*** ERROR: TwinLink initialization failed" << endl;
}
} /* Reflector::initTwinLink */