game2006/server/gameserver/httpproxy.h
aozhiwei b68eff5b5e 1
2024-07-30 17:56:24 +08:00

44 lines
1.0 KiB
C++

#pragma once
#include <a8/singleton.h>
#include "f8/httpclientpool.h"
struct HttpProxyRequest;
class HttpProxy : public a8::Singleton<HttpProxy>
{
private:
HttpProxy() {};
friend class a8::Singleton<HttpProxy>;
public:
void Init();
void UnInit();
std::string HttpGet(
f8::HttpProxyCb cb,
const char* url,
std::shared_ptr<a8::MutableXObject> url_params
);
std::string HttpPost(
f8::HttpProxyCb cb,
const char* url,
std::shared_ptr<a8::MutableXObject> url_params,
const std::string& content
);
std::shared_ptr<HttpProxyRequest> GetRequest(const std::string& req_id);
void DestoryRequest(std::shared_ptr<HttpProxyRequest> request);
private:
std::string CreateRequestId();
private:
std::map<std::string, std::shared_ptr<HttpProxyRequest>> request_hash_;
std::string request_prefix_;
};