/*! * * Copyright (c) 2024-2026 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file AgentSimController.h * \author (original) Stephen Quong * \date (original) 24-May-2026 * */ #pragma once #include #include #include #include #include #include #include "AgentMessage.h" /*! * \brief Simulates the server side of the LeahiRt ↔ Agent UDS connection. * \details Listens on a Unix domain socket, accepts one client at a time, parses * inbound AgentMessage frames, logs them, and replies with an Ack frame. * Parser state is cleared automatically when the client disconnects. */ class AgentSimController : public QObject { Q_OBJECT public: /*! * \brief Construct an AgentSimController. * \param configPath Path to the INI configuration file. * \param parent Optional QObject parent. */ explicit AgentSimController(const QString &configPath, QObject *parent = nullptr); /*! * \brief Begin listening on the configured socket path. * \details Removes any stale socket file before binding. * \return true on success, false if the server could not bind. */ bool listen(); private Q_SLOTS: void onNewConnection(); void onDisconnected(); void onReadyRead(); private: void handleMessage(const AgentMessage &msg); void logMessage(AgentMessage::MsgId msgId, quint16 sequence, const QByteArray &payload); QSettings _settings; QLocalServer _server; QLocalSocket *_client = nullptr; QByteArray _rxBuf; AgentMessage _rxMsg; };