Polyphase Game Engine
Loading...
Searching...
No Matches
HttpClient.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include <string>
6#include <functional>
7#include <atomic>
8
18struct UpdaterHttpResponse
19{
20 int mStatusCode = 0;
21 std::string mBody;
22 std::string mError;
23
24 bool IsSuccess() const
25 {
26 return mStatusCode >= 200 && mStatusCode < 300;
27 }
28};
29
35using DownloadProgressCallback = std::function<void(size_t downloaded, size_t total)>;
36
43class HttpClient
44{
45public:
51 static bool IsAvailable();
52
57 static std::string GetMissingDependencyMessage();
58
65 static UpdaterHttpResponse Get(const std::string& url, int timeoutMs = 10000);
66
75 static bool DownloadFile(
76 const std::string& url,
77 const std::string& destPath,
78 DownloadProgressCallback progressCallback,
79 std::atomic<bool>& cancelFlag);
80
81private:
82 // Platform-specific initialization
83 static bool InitializePlatform();
84 static void ShutdownPlatform();
85
86 static bool sInitialized;
87 static bool sAvailable;
88};
89
90#endif // EDITOR
bool IsAvailable()
Definition HttpClient.cpp:232
const char * GetMissingDependencyMessage()
Definition HttpClient.cpp:239