diff options
Diffstat (limited to 'jetting-proxy/JettingProxy.cpp')
| -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 ()); + } } |
