22 lines
546 B
C++
22 lines
546 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <curl/curl.h>
|
|
#include <mutex>
|
|
#include "types/VehicleCommand.h"
|
|
#include "nlohmann/json.hpp"
|
|
|
|
class HTTPClient {
|
|
public:
|
|
HTTPClient();
|
|
~HTTPClient();
|
|
|
|
// 发送控制指令
|
|
bool sendCommand(const std::string& host, int port, const std::string& command_path, const VehicleCommand& command) const;
|
|
|
|
private:
|
|
static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp);
|
|
CURL* curl_;
|
|
mutable std::mutex mutex_;
|
|
mutable std::string response_buffer_;
|
|
};
|