Skip to content

Commit

Permalink
add pogr client
Browse files Browse the repository at this point in the history
  • Loading branch information
Ughuuu committed Dec 13, 2024
1 parent 5243dad commit 3d22cbc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions modules/blazium_sdk/pogr/pogr_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "core/version.h"
#include "main/performance.h"
#include "scene/main/http_request.h"
#include "core/object/callable_method_pointer.h"

class POGRClient : public BlaziumClient {
GDCLASS(POGRClient, BlaziumClient);
Expand All @@ -64,7 +63,7 @@ class POGRClient : public BlaziumClient {
protected:
static void _bind_methods() {
ClassDB::bind_method(D_METHOD("init"), &POGRClient::init);
ClassDB::bind_method(D_METHOD("end"), &POGRClient::end);
ClassDB::bind_method(D_METHOD("init_finished", "result"), &POGRClient::init_finished);
ClassDB::bind_method(D_METHOD("data", "data"), &POGRClient::data);
ClassDB::bind_method(D_METHOD("event", "event_name", "event_data", "event_flag", "event_key", "event_type", "event_sub_type"), &POGRClient::event);
ClassDB::bind_method(D_METHOD("logs", "tags", "data", "environment", "log", "service", "severity", "type"), &POGRClient::logs);
Expand Down Expand Up @@ -112,11 +111,13 @@ class POGRClient : public BlaziumClient {

protected:
static void _bind_methods() {
ClassDB::bind_method(D_METHOD("_on_request_completed", "status", "code", "headers", "data"), &POGRResponse::_on_request_completed);
ADD_SIGNAL(MethodInfo("finished", PropertyInfo(Variant::OBJECT, "result", PROPERTY_HINT_RESOURCE_TYPE, "POGRResult")));
}

public:
void _on_request_completed(int p_status, int p_code, const PackedStringArray &p_headers, const PackedByteArray &p_data) {
request->disconnect("request_completed", Callable(this, "_on_request_completed"));
Ref<POGRResult> result;

Check failure on line 121 in modules/blazium_sdk/pogr/pogr_client.h

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor (target=editor tests=yes)

declaration of 'result' shadows a member of 'POGRClient::POGRResponse' [-Werror=shadow]

Check failure on line 121 in modules/blazium_sdk/pogr/pogr_client.h

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor w/ Mono (target=editor)

declaration of 'result' shadows a member of 'POGRClient::POGRResponse' [-Werror=shadow]

Check failure on line 121 in modules/blazium_sdk/pogr/pogr_client.h

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with doubles and GCC sanitizers (target=editor, tests=yes, dev_build=yes, scu_build=yes, precision=double, use_asan=yes, use_ubsan=yes, linker=gold)

declaration of 'result' shadows a member of 'POGRClient::POGRResponse' [-Werror=shadow]

Check failure on line 121 in modules/blazium_sdk/pogr/pogr_client.h

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Editor (target=editor, tests=yes)

the following warning is treated as an error

Check warning on line 121 in modules/blazium_sdk/pogr/pogr_client.h

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Editor (target=editor, tests=yes)

declaration of 'result' hides class member

Check failure on line 121 in modules/blazium_sdk/pogr/pogr_client.h

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release)

declaration of 'result' shadows a member of 'POGRClient::POGRResponse' [-Werror=shadow]

Check failure on line 121 in modules/blazium_sdk/pogr/pogr_client.h

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Template (target=template_release)

the following warning is treated as an error

Check warning on line 121 in modules/blazium_sdk/pogr/pogr_client.h

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Template (target=template_release)

declaration of 'result' hides class member

Check failure on line 121 in modules/blazium_sdk/pogr/pogr_client.h

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Template w/ GCC (target=template_release, tests=yes, use_mingw=yes)

declaration of 'result' shadows a member of 'POGRClient::POGRResponse' [-Werror=shadow]
result.instantiate();
String result_str = String::utf8((const char *)p_data.ptr(), p_data.size());
Expand All @@ -137,7 +138,7 @@ class POGRClient : public BlaziumClient {
void post_request(String p_url, Vector<String> p_headers, Dictionary p_data, POGRClient *p_client) {
request = memnew(HTTPRequest);
p_client->add_child(request);
request->connect("request_completed", callable_mp(this, &POGRResponse::_on_request_completed));
request->connect("request_completed", Callable(this, "_on_request_completed"));
request->request(p_url, p_headers, HTTPClient::METHOD_POST, JSON::stringify(p_data));
}
POGRResponse() {
Expand All @@ -148,7 +149,7 @@ class POGRClient : public BlaziumClient {
Ref<POGRResponse> init() {
Ref<POGRResponse> response;
response.instantiate();
response->connect("finished", callable_mp(this, &POGRClient::init_finished));
response->connect("finished", Callable(this, "init_finished"));
Dictionary dict_data;
dict_data["association_id"] = OS::get_singleton()->get_unique_id();
response->post_request(POGR_URL + "/init", get_init_headers(), dict_data, this);
Expand Down Expand Up @@ -188,7 +189,7 @@ class POGRClient : public BlaziumClient {
data["event_key"] = event_key;
data["event_type"] = event_type;
data["sub_event"] = event_sub_type;
response->post_request(POGR_URL + "/event", get_session_headers(), data, this);
response->post_request(POGR_URL + "/end", get_session_headers(), data, this);
return response;
}

Expand All @@ -215,7 +216,7 @@ class POGRClient : public BlaziumClient {
data["environment"] = p_environment;
data["metrics"] = p_metrics;
data["service"] = p_service;
response->post_request(POGR_URL + "/metrics", get_session_headers(), data, this);
response->post_request(POGR_URL + "/logs", get_session_headers(), data, this);
return response;
}

Expand All @@ -227,7 +228,7 @@ class POGRClient : public BlaziumClient {
data["cpu_usage"] = Performance::get_singleton()->get_monitor(Performance::Monitor::TIME_FPS);
data["dlls_loaded"] = Array();
data["memory_usage"] = OS::get_singleton()->get_static_memory_usage();
response->post_request(POGR_URL + "/monitor", get_session_headers(), data, this);
response->post_request(POGR_URL + "/logs", get_session_headers(), data, this);
return response;
}

Expand Down

0 comments on commit 3d22cbc

Please sign in to comment.