/*! * * 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 CloudConnectServer.h * \author (original) Stephen Quong * \date (original) 15-Jul-2026 * */ #pragma once #include #include #include #include #include #include "CloudConnectFrame.h" /*! * \brief Server to handle incoming local socket connections to the CloudConnect agent. */ class CloudConnectServer : public QObject { Q_OBJECT public: explicit CloudConnectServer(QObject *parent = nullptr); bool listen(const QString &socketPath); bool send(CloudConnectFrame::MsgId msgId, quint16 sequence, const QByteArray &payload = {}); bool isConnected() const; Q_SIGNALS: /*! * \brief didMessageReceive * \details Emitted when a complete inbound CloudConnectFrame has been parsed. * \param msgId - message identifier from the frame header * \param sequence - sequence number from the frame header * \param payload - decoded payload bytes, empty for zero-length frames */ void didMessageReceive(CloudConnectFrame::MsgId msgId, quint16 sequence, QByteArray payload); /*! * \brief didConnect * \details Emitted when a client connects. */ void didConnect(); /*! * \brief didDisconnect * \details Emitted when the connected client disconnects. */ void didDisconnect(); private Q_SLOTS: void onNewConnection(); void onDisconnected(); void onReadyRead(); private: QLocalServer _server; QLocalSocket *_client = nullptr; QByteArray _rxBuf; CloudConnectFrame _rxMsg; };