/** * @file MockServer.h * @brief Mock XPL2 server — listens on all three protocol ports. */ #pragma once #include #include #include #include class QTcpSocket; class MockServer : public QObject { Q_OBJECT 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: struct Port { QTcpServer server; const char *name = nullptr; quint16 number = 0; }; void setupPort (Port &port, const char *name, quint16 number); /* 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 m_clients; QTimer m_pingTimer; static bool s_wireDebug; };