diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-16 14:56:46 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-06-16 14:56:46 +0200 |
| commit | bf525d35301dcf0c612598f4394e4357b8378746 (patch) | |
| tree | 25e104bd7c24ae22337e7e07385b67eca5053a3f /jetting-proxy | |
| parent | e9d8a8b052150f42ea00da2c07e3f78a9b7d2061 (diff) | |
| download | QtXpl2-bf525d35301dcf0c612598f4394e4357b8378746.tar.gz QtXpl2-bf525d35301dcf0c612598f4394e4357b8378746.zip | |
fix: make ping exchange follow the protocol specification
Diffstat (limited to 'jetting-proxy')
| -rw-r--r-- | jetting-proxy/JettingProxy.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/jetting-proxy/JettingProxy.cpp b/jetting-proxy/JettingProxy.cpp index 30fe7df..6c70f47 100644 --- a/jetting-proxy/JettingProxy.cpp +++ b/jetting-proxy/JettingProxy.cpp @@ -159,8 +159,13 @@ JettingProxy::onControllerDataReady () if (cmd == "KA_PING") { - /* Reply directly — never forward keepalive to clients. */ - socket->write ("KA_PING,1\n"); + /* Controller's reply to our keepalive ping — consume it, never + forward to clients. */ + QByteArray wire; + if (s_wireDebug) + wire = " << " + trimmed; + qDebug ("%s RX KA_PING ← controller%s", qPrintable (logTag (*ch)), + wire.constData ()); continue; } @@ -230,14 +235,6 @@ JettingProxy::onClientDataReady () QByteArray line = socket->readLine (); QByteArray trimmed = line.trimmed (); - /* Extract command token. */ - int comma = trimmed.indexOf (','); - QByteArray cmd = (comma >= 0) ? trimmed.left (comma) : trimmed; - - /* Absorb keepalive replies — never forward to controller. */ - if (cmd == "KA_PING") - continue; - if (s_wireDebug) qDebug ("%s Client → controller: %s", qPrintable (logTag (*ch)), trimmed.constData ()); @@ -259,8 +256,17 @@ JettingProxy::onClientDataReady () void JettingProxy::tick () { + /* The proxy is the interface: it originates keepalive pings to the + controller. Clients take no part in keepalive. */ for (auto *ch : { &m_command, &m_imaging, &m_status }) - for (auto *client : ch->clientSockets) - if (client->state () == QAbstractSocket::ConnectedState) - client->write ("KA_PING\n"); + if (ch->controllerSocket + && ch->controllerSocket->state () == QAbstractSocket::ConnectedState) + { + ch->controllerSocket->write ("KA_PING\n"); + QByteArray wire; + if (s_wireDebug) + wire = " >> KA_PING"; + qDebug ("%s TX KA_PING → controller%s", qPrintable (logTag (*ch)), + wire.constData ()); + } } |
