mirror of
https://github.com/tribufu/sdk-cpp
synced 2025-06-16 13:34:19 +00:00
Use mintaka shared libraries (#1)
* Add libhv and test http client * Remove cpp-httplib * Update premake5.lua * Update client.cpp * Update premake5.lua * Add more windows libs * Use mintaka http client
This commit is contained in:
@ -8,9 +8,33 @@ namespace tribufu
|
||||
{
|
||||
this->id = id;
|
||||
this->secret = secret;
|
||||
this->http = HttpClient();
|
||||
}
|
||||
|
||||
TribufuClient::~TribufuClient()
|
||||
{
|
||||
}
|
||||
|
||||
void TribufuClient::get_token()
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string url = "https://api.tribufu.com/v1/servers";
|
||||
FHttpResponse response = this->http.get(url);
|
||||
std::cout << "status_code: " << response.status_code << std::endl;
|
||||
|
||||
if (response.body != nullptr)
|
||||
{
|
||||
json response_body = json::parse(response.body);
|
||||
std::string json_str = response_body.dump(4);
|
||||
std::cout << json_str << std::endl;
|
||||
}
|
||||
|
||||
mintaka_http_free_response(response);
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
std::cout << "exception: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1
src/lib.rs
Normal file
1
src/lib.rs
Normal file
@ -0,0 +1 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
92
src/oauth2.cpp
Normal file
92
src/oauth2.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#include <tribufu/oauth2.h>
|
||||
|
||||
namespace tribufu
|
||||
{
|
||||
OAuth2AuthorizeRequest::OAuth2AuthorizeRequest()
|
||||
{
|
||||
}
|
||||
|
||||
OAuth2AuthorizeRequest::OAuth2AuthorizeRequest(OAuth2ResponseType response_type, uint64_t client_id, const std::string &client_secret, const std::string &redirect_uri, const std::string &scope, const std::string &state)
|
||||
{
|
||||
this->response_type = response_type;
|
||||
this->client_id = client_id;
|
||||
this->client_secret = client_secret;
|
||||
this->redirect_uri = redirect_uri;
|
||||
this->scope = scope;
|
||||
this->state = state;
|
||||
}
|
||||
|
||||
OAuth2AuthorizeRequest::~OAuth2AuthorizeRequest()
|
||||
{
|
||||
}
|
||||
|
||||
OAuth2CodeResponse::OAuth2CodeResponse()
|
||||
{
|
||||
}
|
||||
|
||||
OAuth2CodeResponse::OAuth2CodeResponse(const std::string &code, const std::string &state)
|
||||
{
|
||||
this->code = code;
|
||||
this->state = state;
|
||||
}
|
||||
|
||||
OAuth2CodeResponse::~OAuth2CodeResponse()
|
||||
{
|
||||
}
|
||||
|
||||
OAuth2ErrorResponse::OAuth2ErrorResponse()
|
||||
{
|
||||
}
|
||||
|
||||
OAuth2ErrorResponse::OAuth2ErrorResponse(OAuth2AuthorizeError error, const std::string &error_description, const std::string &error_uri, const std::string &state)
|
||||
{
|
||||
this->error = error;
|
||||
this->error_description = error_description;
|
||||
this->error_uri = error_uri;
|
||||
this->state = state;
|
||||
}
|
||||
|
||||
OAuth2ErrorResponse::~OAuth2ErrorResponse()
|
||||
{
|
||||
}
|
||||
|
||||
OAuth2TokenRequest::OAuth2TokenRequest()
|
||||
{
|
||||
}
|
||||
|
||||
OAuth2TokenRequest::OAuth2TokenRequest(OAuth2GrantType grant_type, uint64_t client_id, const std::string &client_secret, const std::string &redirect_uri, const std::string &code, const std::string &refresh_token, const std::string &username, const std::string &password)
|
||||
{
|
||||
this->grant_type = grant_type;
|
||||
this->client_id = client_id;
|
||||
this->client_secret = client_secret;
|
||||
this->redirect_uri = redirect_uri;
|
||||
this->code = code;
|
||||
this->refresh_token = refresh_token;
|
||||
this->username = username;
|
||||
this->password = password;
|
||||
}
|
||||
|
||||
OAuth2TokenRequest::~OAuth2TokenRequest()
|
||||
{
|
||||
}
|
||||
|
||||
OAuth2TokenResponse::OAuth2TokenResponse()
|
||||
{
|
||||
}
|
||||
|
||||
OAuth2TokenResponse::OAuth2TokenResponse(OAuth2TokenType token_type, const std::string &access_token, const std::string &refresh_token, const std::string &scope, const std::string &state, uint64_t expires_in)
|
||||
{
|
||||
this->token_type = token_type;
|
||||
this->access_token = access_token;
|
||||
this->refresh_token = refresh_token;
|
||||
this->scope = scope;
|
||||
this->state = state;
|
||||
this->expires_in = expires_in;
|
||||
}
|
||||
|
||||
OAuth2TokenResponse::~OAuth2TokenResponse()
|
||||
{
|
||||
}
|
||||
}
|
@ -25,12 +25,13 @@ project "tribufu_cpp"
|
||||
includedirs
|
||||
{
|
||||
"../include",
|
||||
"../vendor",
|
||||
"../vendor/*/include",
|
||||
}
|
||||
|
||||
libdirs
|
||||
{
|
||||
"../bin/%{cfg.platform:gsub('-', '/')}",
|
||||
"../vendor/*/lib/%{cfg.platform:gsub('-', '/')}",
|
||||
}
|
||||
|
||||
-- Profile
|
||||
@ -77,12 +78,19 @@ project "tribufu_cpp"
|
||||
|
||||
links
|
||||
{
|
||||
"tribufu_native.lib",
|
||||
"mintaka_native.dll.lib",
|
||||
}
|
||||
|
||||
prelinkcommands
|
||||
{
|
||||
}
|
||||
|
||||
postbuildcommands
|
||||
{
|
||||
"{COPYFILE} ../target/%{cfg.buildcfg}/deps/mintaka_native.dll %{cfg.targetdir}/mintaka_native.dll",
|
||||
}
|
||||
|
||||
filter { "platforms:mac-*" }
|
||||
kind "SharedLib"
|
||||
system "macosx"
|
||||
@ -101,12 +109,18 @@ project "tribufu_cpp"
|
||||
|
||||
links
|
||||
{
|
||||
"tribufu_native",
|
||||
"mintaka_native",
|
||||
}
|
||||
|
||||
prelinkcommands
|
||||
{
|
||||
}
|
||||
|
||||
postbuildcommands
|
||||
{
|
||||
}
|
||||
|
||||
filter { "platforms:linux-*" }
|
||||
kind "SharedLib"
|
||||
system "linux"
|
||||
@ -124,12 +138,18 @@ project "tribufu_cpp"
|
||||
|
||||
links
|
||||
{
|
||||
"tribufu_native",
|
||||
"mintaka_native",
|
||||
}
|
||||
|
||||
prelinkcommands
|
||||
{
|
||||
}
|
||||
|
||||
postbuildcommands
|
||||
{
|
||||
}
|
||||
|
||||
filter { "platforms:android-*" }
|
||||
kind "SharedLib"
|
||||
system "android"
|
||||
@ -147,12 +167,18 @@ project "tribufu_cpp"
|
||||
|
||||
links
|
||||
{
|
||||
"tribufu_native",
|
||||
"mintaka_native",
|
||||
}
|
||||
|
||||
prelinkcommands
|
||||
{
|
||||
}
|
||||
|
||||
postbuildcommands
|
||||
{
|
||||
}
|
||||
|
||||
filter { "platforms:ios-*" }
|
||||
kind "StaticLib"
|
||||
system "ios"
|
||||
@ -170,6 +196,16 @@ project "tribufu_cpp"
|
||||
}
|
||||
|
||||
links
|
||||
{
|
||||
"tribufu_native",
|
||||
"mintaka_native",
|
||||
}
|
||||
|
||||
prelinkcommands
|
||||
{
|
||||
}
|
||||
|
||||
postbuildcommands
|
||||
{
|
||||
}
|
||||
|
||||
|
38
src/servers/server.cpp
Normal file
38
src/servers/server.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#include <tribufu/servers/server.h>
|
||||
|
||||
namespace tribufu
|
||||
{
|
||||
Server::Server()
|
||||
{
|
||||
}
|
||||
|
||||
Server::Server(json data)
|
||||
{
|
||||
this->id = data["id"];
|
||||
this->name = data["name"];
|
||||
this->description = data["description"];
|
||||
this->address = data["address"];
|
||||
this->game_port = data["game_port"];
|
||||
this->query_port = data["query_port"];
|
||||
this->package_id = data["package_id"];
|
||||
}
|
||||
|
||||
Server::~Server()
|
||||
{
|
||||
}
|
||||
|
||||
json Server::to_json()
|
||||
{
|
||||
json data;
|
||||
data["id"] = this->id;
|
||||
data["name"] = this->name;
|
||||
data["description"] = this->description;
|
||||
data["address"] = this->address;
|
||||
data["game_port"] = this->game_port;
|
||||
data["query_port"] = this->query_port;
|
||||
data["package_id"] = this->package_id;
|
||||
return data;
|
||||
}
|
||||
}
|
62
src/users/profile.cpp
Normal file
62
src/users/profile.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#include <tribufu/users/profile.h>
|
||||
|
||||
namespace tribufu
|
||||
{
|
||||
Profile::Profile()
|
||||
{
|
||||
}
|
||||
|
||||
Profile::Profile(json data)
|
||||
{
|
||||
this->id = data["id"];
|
||||
this->uuid = data["uuid"];
|
||||
this->name = data["name"];
|
||||
this->display_name = data["display_name"];
|
||||
this->type = data["type"];
|
||||
this->public_flags = data["public_flags"];
|
||||
this->verified = data["verified"];
|
||||
this->level = data["level"];
|
||||
this->experience = data["experience"];
|
||||
this->public_birthday = data["public_birthday"];
|
||||
this->points = data["points"];
|
||||
this->location = data["location"];
|
||||
this->photo_url = data["photo_url"];
|
||||
this->banner_url = data["banner_url"];
|
||||
this->last_online = data["last_online"];
|
||||
this->biography = data["biography"];
|
||||
this->view_count = data["view_count"];
|
||||
this->created = data["created"];
|
||||
this->updated = data["updated"];
|
||||
}
|
||||
|
||||
Profile::~Profile()
|
||||
{
|
||||
}
|
||||
|
||||
json Profile::to_json()
|
||||
{
|
||||
json data;
|
||||
data["id"] = this->id;
|
||||
data["uuid"] = this->uuid;
|
||||
data["name"] = this->name;
|
||||
data["display_name"] = this->display_name;
|
||||
data["type"] = this->type;
|
||||
data["public_flags"] = this->public_flags;
|
||||
data["verified"] = this->verified;
|
||||
data["level"] = this->level;
|
||||
data["experience"] = this->experience;
|
||||
data["public_birthday"] = this->public_birthday;
|
||||
data["points"] = this->points;
|
||||
data["location"] = this->location;
|
||||
data["photo_url"] = this->photo_url;
|
||||
data["banner_url"] = this->banner_url;
|
||||
data["last_online"] = this->last_online;
|
||||
data["biography"] = this->biography;
|
||||
data["view_count"] = this->view_count;
|
||||
data["created"] = this->created;
|
||||
data["updated"] = this->updated;
|
||||
return data;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user