#pragma once #include #include #include #include #include #include #include #include "ShrinkwrapTypes.h" struct PendingTask { ShrinkwrapShellRequest request; ShrinkwrapShellResult result; std::string error; bool completed = false; bool success = false; }; class HttpServer { public: HttpServer(); ~HttpServer(); using TriggerCallback = void(*)(); bool Start(int port, std::string* err, TriggerCallback trigger = nullptr); void Stop(); // Called from Creo main thread via idle notification void ProcessPendingTask(); bool HasPendingTask() const; private: void Run(); void HandleClient(SOCKET client); std::atomic stop_{false}; std::thread thread_; SOCKET listen_ = INVALID_SOCKET; int port_ = 0; // Task queue (single task for simplicity) mutable std::mutex task_mutex_; std::condition_variable task_cv_; PendingTask* pending_task_ = nullptr; TriggerCallback trigger_callback_ = nullptr; };