Advertisement
massacring

WebSocketClient.h

Jul 23rd, 2024 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #pragma once
  2. #include <Windows.h>
  3. #include <winhttp.h>
  4. #include <iostream>
  5. #include <nlohmann/json.hpp>
  6.  
  7. #pragma comment(lib, "winhttp.lib")
  8. class WebSocketClient {
  9.     using json = nlohmann::json;
  10. private:
  11.     HINTERNET hSession = NULL;
  12.     HINTERNET hConnect = NULL;
  13.     HINTERNET hRequest = NULL;
  14.     HANDLE hWebSocket = NULL;
  15. public:
  16.     WebSocketClient();
  17.  
  18.     ~WebSocketClient();
  19.  
  20.     bool Connect(const wchar_t* host, int port, const wchar_t* path);
  21.  
  22.     bool Send(const json& j) const;
  23.  
  24.     std::string Receive() const;
  25.  
  26.     bool CheckConnection() const;
  27. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement