diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-13 11:47:00 +0100 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-13 11:47:00 +0100 |
| commit | a2b1ccf17845e55caef7f69a5e68f49a55b6a166 (patch) | |
| tree | a7e8c414dbadeeb9bcac29478cf3fbf7e99a4a05 /mock-server/EchoServer.h | |
| parent | 34faf3cdea798c1948229ec1bb53c828e2b40bb7 (diff) | |
| download | QtXpl2-a2b1ccf17845e55caef7f69a5e68f49a55b6a166.tar.gz QtXpl2-a2b1ccf17845e55caef7f69a5e68f49a55b6a166.zip | |
XPL2 protocol foundation: wire framing, typed API, KA_PING, GS_JC_VERSION
Add Xpl2Protocol namespace with buildMessage/parseMessage for wire
serialization. Replace raw send/receive API on Xpl2Client with typed
protocol methods and internal dispatch. Auto-reply to KA_PING on all
sockets (qDebug only). Add GS_JC_VERSION as first typed command with
controllerId, firmwareVersion, hardwareVersion, printheadCount properties.
Upgrade mock server from echo to line-based command dispatch with 1s
KA_PING timer and canned GS_JC_VERSION response. Unknown commands
produce qWarning instead of echo.
Overhaul demo: remove raw send UI and port config, add wireDebug
toggle and Get JC Version button.
Diffstat (limited to 'mock-server/EchoServer.h')
| -rw-r--r-- | mock-server/EchoServer.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/mock-server/EchoServer.h b/mock-server/EchoServer.h index 2e51b1e..c0a41c9 100644 --- a/mock-server/EchoServer.h +++ b/mock-server/EchoServer.h @@ -1,10 +1,14 @@ /** * @file EchoServer.h - * @brief Simple TCP echo server for a single port. + * @brief Mock XPL2 server for a single port. */ #pragma once +#include <QList> #include <QTcpServer> +#include <QTimer> + +class QTcpSocket; class EchoServer : public QTcpServer { @@ -15,10 +19,15 @@ public: private slots: void onNewConnection (); - void onClientReadyRead (); + void onClientMessageReady (); void onClientDisconnected (); + void sendKaPing (); private: + void handleCommand (QTcpSocket *client, const QByteArray &line); + const char *m_name; quint16 m_port; + QList<QTcpSocket *> m_clients; + QTimer m_pingTimer; }; |
