summaryrefslogtreecommitdiffstats
path: root/veslibrary/ves_cpplibrary/src/lib/transport/XLibcurlTransport.h
diff options
context:
space:
mode:
Diffstat (limited to 'veslibrary/ves_cpplibrary/src/lib/transport/XLibcurlTransport.h')
-rwxr-xr-xveslibrary/ves_cpplibrary/src/lib/transport/XLibcurlTransport.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/veslibrary/ves_cpplibrary/src/lib/transport/XLibcurlTransport.h b/veslibrary/ves_cpplibrary/src/lib/transport/XLibcurlTransport.h
new file mode 100755
index 0000000..544a5c4
--- /dev/null
+++ b/veslibrary/ves_cpplibrary/src/lib/transport/XLibcurlTransport.h
@@ -0,0 +1,41 @@
+#pragma once
+
+#include <atomic>
+#include <chrono>
+#include <mutex>
+#include <string>
+#include <curl/curl.h>
+#include "XTransport.h"
+
+namespace vagt
+{
+ namespace transport
+ {
+ class XLibcurlTransport: public XTransport
+ {
+ public:
+ XLibcurlTransport(const XTransportOption& option);
+
+ virtual ~XLibcurlTransport() {}
+
+ virtual XErrorCode start() override;
+
+ virtual XErrorCode stop() override;
+
+ virtual XErrorCode post(const std::string& event) override;
+
+ private:
+ XErrorCode initLibcurl();
+ XErrorCode cleanupLibcurl();
+ XErrorCode curlPost(const std::string& body);
+
+ static char curlErrorBuf_[CURL_ERROR_SIZE];
+ static size_t readCallback(void *ptr, size_t size, size_t nmemb, void *userp);
+ static size_t writeCallback(void *ptr, size_t size, size_t nmemb, void *userp);
+
+ XTransportOption option_;
+ CURL* curl_;
+ struct curl_slist* hdr_;
+ };
+ }
+}