mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 03:51:50 +00:00
add httpGet error handling
This commit is contained in:
parent
d7389c2220
commit
4328c83c79
3 changed files with 36 additions and 11 deletions
|
|
@ -9,13 +9,18 @@
|
|||
#include "util/Buffer.hpp"
|
||||
|
||||
namespace network {
|
||||
using OnResponse = std::function<void(int, std::vector<char>)>;
|
||||
using OnResponse = std::function<void(std::vector<char>)>;
|
||||
using OnReject = std::function<void(const char*)>;
|
||||
|
||||
class Http {
|
||||
public:
|
||||
virtual ~Http() {}
|
||||
|
||||
virtual void get(const std::string& url, const OnResponse& callback) = 0;
|
||||
virtual void get(
|
||||
const std::string& url,
|
||||
OnResponse onResponse,
|
||||
OnReject onReject=nullptr
|
||||
) = 0;
|
||||
virtual size_t getTotalUpload() const = 0;
|
||||
virtual size_t getTotalDownload() const = 0;
|
||||
};
|
||||
|
|
@ -26,7 +31,11 @@ namespace network {
|
|||
Network(std::unique_ptr<Http> http);
|
||||
~Network();
|
||||
|
||||
void httpGet(const std::string& url, const OnResponse& callback);
|
||||
void httpGet(
|
||||
const std::string& url,
|
||||
OnResponse onResponse,
|
||||
OnReject onReject = nullptr
|
||||
);
|
||||
|
||||
size_t getTotalUpload() const;
|
||||
size_t getTotalDownload() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue