diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-13 18:20:35 +0100 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-13 18:20:35 +0100 |
| commit | 87169e10cb7ebe732ef388552bb0c057c09767ef (patch) | |
| tree | fba2c9e2255cb02553c43fb37d653a47574824ba /mock-server/MockServer.h | |
| parent | 02fe86ab2a04a02b114d7ca8ce4374a29a1d5f45 (diff) | |
| download | QtXpl2-87169e10cb7ebe732ef388552bb0c057c09767ef.tar.gz QtXpl2-87169e10cb7ebe732ef388552bb0c057c09767ef.zip | |
Unified socket slots, --wire-debug CLI flag, fix mock TX and disconnect logging
Collapse 12 per-socket slots into 4 sender()-based slots. Replace runtime
wireDebug QML property with static --wire-debug CLI flag on both demo and
mock server. Route MockServer::sendKaPing through sendReply so KA_PING TX
shows wire bytes. Simplify sendReply to deduce command token from wire data.
Fix Xpl2Client disconnect logging (logTag takes pointer, null-sender fallback).
Diffstat (limited to 'mock-server/MockServer.h')
| -rw-r--r-- | mock-server/MockServer.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/mock-server/MockServer.h b/mock-server/MockServer.h index 21d4d32..13bb2cd 100644 --- a/mock-server/MockServer.h +++ b/mock-server/MockServer.h @@ -17,11 +17,13 @@ class MockServer : public QObject public: explicit MockServer (QObject *parent = nullptr); + static void enableWireDebug (); private slots: void onNewConnection (); void onClientMessageReady (); void onClientDisconnected (); + /* Send KA_PING keepalive to all connected clients. */ void sendKaPing (); private: @@ -33,12 +35,18 @@ private: }; void setupPort (Port &port, const char *name, quint16 number); - const char *portName (quint16 localPort) const; + /* Return a fixed-width "[Name:port]" tag for log lines. */ + QString logTag (quint16 localPort) const; + /* Parse incoming line, log RX, and dispatch to the matching handler. */ void handleCommand (QTcpSocket *client, const QByteArray &line); + void sendReply (QTcpSocket *client, const QByteArray &data); + void handleKaPing (QTcpSocket *client, const QByteArray ¶ms); + void handleGsJcVersion (QTcpSocket *client); Port m_command; Port m_imaging; Port m_status; QList<QTcpSocket *> m_clients; QTimer m_pingTimer; + static bool s_wireDebug; }; |
