#ifndef PARKINGSPACEGUIDEREMOTESERVER_H #define PARKINGSPACEGUIDEREMOTESERVER_H #include #include #include #include #include #include #include #include "IVrConfig.h" class IVrZeroMQPublisher; class IVrZeroMQServer; class QJsonObject; class QUdpSocket; class ParkingSpaceGuideRemoteServer : public QObject { public: using ModelHandler = std::function; using StartHandler = std::function; using StopHandler = std::function; using StatusProvider = std::function; using RunningProvider = std::function; using LogHandler = std::function; explicit ParkingSpaceGuideRemoteServer(QObject* parent = nullptr); ~ParkingSpaceGuideRemoteServer() override; bool Start(const RemoteViewConfig& config, ModelHandler modelHandler, StartHandler startHandler, StopHandler stopHandler, StatusProvider statusProvider, RunningProvider runningProvider, LogHandler logHandler); void Stop(); bool IsRunning() const; bool PublishStatus(const std::string& statusJson); QString LastError() const; private: QByteArray HandleControlMessage(const QByteArray& request); void HandleDiscoveryDatagrams(); QJsonObject BuildServerInfo(const QString& command) const; std::string DeviceId() const; void SetError(const QString& message); private: RemoteViewConfig m_config; IVrZeroMQServer* m_controlServer = nullptr; IVrZeroMQPublisher* m_statusPublisher = nullptr; QUdpSocket* m_discoverySocket = nullptr; ModelHandler m_modelHandler; StartHandler m_startHandler; StopHandler m_stopHandler; StatusProvider m_statusProvider; RunningProvider m_runningProvider; LogHandler m_logHandler; std::atomic m_running{false}; mutable std::mutex m_publishMutex; mutable std::mutex m_errorMutex; QString m_lastError; }; #endif // PARKINGSPACEGUIDEREMOTESERVER_H