mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 03:51:50 +00:00
add Network.httpGet (WIP)
This commit is contained in:
parent
a5d87c9fc4
commit
46dfdac998
5 changed files with 113 additions and 18 deletions
31
src/network/Network.hpp
Normal file
31
src/network/Network.hpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
#include "typedefs.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "util/Buffer.hpp"
|
||||
|
||||
namespace network {
|
||||
using OnResponse = std::function<void(int, std::vector<char>)>;
|
||||
|
||||
class Http {
|
||||
public:
|
||||
virtual ~Http() {}
|
||||
|
||||
virtual void get(const std::string& url, const OnResponse& callback) = 0;
|
||||
};
|
||||
|
||||
class Network {
|
||||
std::unique_ptr<Http> http;
|
||||
public:
|
||||
Network(std::unique_ptr<Http> http);
|
||||
~Network();
|
||||
|
||||
void httpGet(const std::string& url, const OnResponse& callback);
|
||||
|
||||
static std::unique_ptr<Network> create(const NetworkSettings& settings);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue