中间件底层,websocket

HttpClient.h 766B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. // curl
  3. #define USE_OPENSSL
  4. #define CURL_STATICLIB
  5. #include <curl/curl.h>
  6. #pragma comment(lib, "ws2_32.lib")
  7. #pragma comment(lib, "wldap32.lib")
  8. #pragma comment(lib, "libcurl.lib")
  9. #pragma comment(lib,"Crypt32.lib")
  10. #include <json/json.h>
  11. #pragma comment(lib,"jsoncpp_static.lib")
  12. class CHttpClient
  13. {
  14. public:
  15. BOOL sendWarnMsg(const char* postParams);
  16. CURLcode curl_post_req(const char* url, const char* postParams, std::string &response);
  17. static CHttpClient* GetInStance() { return &sp; }
  18. private:
  19. CHttpClient() {};
  20. CHttpClient(const CHttpClient&);
  21. CHttpClient& operator = (const CHttpClient&) = delete;
  22. ~CHttpClient() {};
  23. static size_t req_reply(void * ptr, size_t size, size_t nmemb, void * stream);
  24. static CHttpClient sp;
  25. };