Skip to content

Commit ab2563b

Browse files
committed
rename GAHttpWrapper to GAHttpClient
1 parent 1761269 commit ab2563b

File tree

9 files changed

+34
-34
lines changed

9 files changed

+34
-34
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ gameAnalytics_configureCustomLogHandler(myLogHandler);
126126

127127
### Custom HTTP client
128128

129-
By default, the SDK uses cURL for HTTP requests. If you need to use a different HTTP library (e.g. on consoles or custom platforms), you can provide your own implementation by subclassing `GAHttpWrapper`:
129+
By default, the SDK uses cURL for HTTP requests. If you need to use a different HTTP library (e.g. on consoles or custom platforms), you can provide your own implementation by subclassing `GAHttpClient`:
130130

131131
``` c++
132-
#include "GameAnalytics/GAHttpWrapper.h"
132+
#include "GameAnalytics/GAHttpClient.h"
133133

134-
class MyHttpClient : public gameanalytics::GAHttpWrapper
134+
class MyHttpClient : public gameanalytics::GAHttpClient
135135
{
136136
public:
137137
void initialize() override
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace gameanalytics
99
{
10-
class GAHttpWrapper
10+
class GAHttpClient
1111
{
1212
public:
1313

@@ -23,7 +23,7 @@ namespace gameanalytics
2323
}
2424
};
2525

26-
virtual ~GAHttpWrapper() {};
26+
virtual ~GAHttpClient() {};
2727

2828
virtual void initialize() = 0;
2929

include/GameAnalytics/GameAnalytics.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#pragma once
77

88
#include "GameAnalytics/GATypes.h"
9-
#include "GameAnalytics/GAHttpWrapper.h"
9+
#include "GameAnalytics/GAHttpClient.h"
1010

1111
namespace gameanalytics
1212
{
@@ -65,7 +65,7 @@ namespace gameanalytics
6565

6666
// Set a custom HTTP implementation. Must be called before initialize().
6767
// If not called, the default cURL implementation is used.
68-
static void configureHttpClient(std::unique_ptr<GAHttpWrapper> httpClient);
68+
static void configureHttpClient(std::unique_ptr<GAHttpClient> httpClient);
6969

7070
// initialize - starting SDK (need configuration before starting)
7171
static void initialize(std::string const& gameKey, std::string const& gameSecret);

source/gameanalytics/GAHTTPApi.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace gameanalytics
2323
constexpr int HTTP_RESPONSE_UNAUTHORIZED = 401;
2424
constexpr int HTTP_RESPONSE_INTERNAL_ERROR = 500;
2525

26-
std::unique_ptr<GAHttpWrapper> GAHTTPApi::pendingCustomImpl = nullptr;
26+
std::unique_ptr<GAHttpClient> GAHTTPApi::pendingCustomImpl = nullptr;
2727

2828
// Constructor - setup the basic information for HTTP
2929
GAHTTPApi::GAHTTPApi():
@@ -58,7 +58,7 @@ namespace gameanalytics
5858
return state::GAState::getInstance()._gaHttp;
5959
}
6060

61-
void GAHTTPApi::setCustomHttpImpl(std::unique_ptr<GAHttpWrapper> customImpl)
61+
void GAHTTPApi::setCustomHttpImpl(std::unique_ptr<GAHttpClient> customImpl)
6262
{
6363
pendingCustomImpl = std::move(customImpl);
6464
}
@@ -92,7 +92,7 @@ namespace gameanalytics
9292
std::vector<uint8_t> payloadData = createPayloadData(jsonString, useGzip);
9393

9494
std::string const auth = createAuth(payloadData);
95-
GAHttpWrapper::Response response = impl->sendRequest(url, auth, payloadData, useGzip, nullptr);
95+
GAHttpClient::Response response = impl->sendRequest(url, auth, payloadData, useGzip, nullptr);
9696

9797
if(response.code < 0)
9898
{
@@ -197,7 +197,7 @@ namespace gameanalytics
197197
std::vector<uint8_t> payloadData = createPayloadData(jsonString, useGzip);
198198

199199
std::string const auth = createAuth(payloadData);
200-
GAHttpWrapper::Response response = impl->sendRequest(url, auth, payloadData, useGzip, nullptr);
200+
GAHttpClient::Response response = impl->sendRequest(url, auth, payloadData, useGzip, nullptr);
201201

202202
if(response.code < 0)
203203
{
@@ -337,7 +337,7 @@ namespace gameanalytics
337337
std::vector<uint8_t> payloadData = getInstance().createPayloadData(payloadJSONString, useGzip);
338338

339339
std::string auth = createAuth(payloadData);
340-
GAHttpWrapper::Response response = impl->sendRequest(url, auth, payloadData, useGzip, nullptr);
340+
GAHttpClient::Response response = impl->sendRequest(url, auth, payloadData, useGzip, nullptr);
341341

342342
if(response.code < 0)
343343
{
@@ -383,7 +383,7 @@ namespace gameanalytics
383383
return payloadData;
384384
}
385385

386-
EGAHTTPApiResponse GAHTTPApi::processRequestResponse(GAHttpWrapper::Response const& response, std::string const& requestId)
386+
EGAHTTPApiResponse GAHTTPApi::processRequestResponse(GAHttpClient::Response const& response, std::string const& requestId)
387387
{
388388
// if no result - often no connection
389389
if (response.packet.empty() && response.code != HTTP_RESPONSE_NO_CONTENT)

source/gameanalytics/GAHTTPApi.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#pragma once
77

88
#include "GACommon.h"
9-
#include "GameAnalytics/GAHttpWrapper.h"
9+
#include "GameAnalytics/GAHttpClient.h"
1010

1111
#include <vector>
1212
#include <map>
@@ -127,7 +127,7 @@ namespace gameanalytics
127127

128128
static GAHTTPApi& getInstance();
129129

130-
static void setCustomHttpImpl(std::unique_ptr<GAHttpWrapper> customImpl);
130+
static void setCustomHttpImpl(std::unique_ptr<GAHttpClient> customImpl);
131131

132132
EGAHTTPApiResponse requestInitReturningDict(json& json_out, std::string const& configsHash);
133133
EGAHTTPApiResponse sendEventsInArray(json& json_out, const json& eventArray);
@@ -141,9 +141,9 @@ namespace gameanalytics
141141
GAHTTPApi& operator=(const GAHTTPApi&) = delete;
142142
std::vector<uint8_t> createPayloadData(std::string const& payload, bool gzip);
143143
std::string createAuth(std::vector<uint8_t> const& payload);
144-
EGAHTTPApiResponse processRequestResponse(GAHttpWrapper::Response const& response, std::string const& requestId);
144+
EGAHTTPApiResponse processRequestResponse(GAHttpClient::Response const& response, std::string const& requestId);
145145

146-
std::unique_ptr<GAHttpWrapper> impl;
146+
std::unique_ptr<GAHttpClient> impl;
147147

148148
std::string protocol = PROTOCOL;
149149
std::string hostName = HOST_NAME;
@@ -162,7 +162,7 @@ namespace gameanalytics
162162
std::map<ErrorType, int> countMap;
163163
std::map<ErrorType, int64_t> timestampMap;
164164

165-
static std::unique_ptr<GAHttpWrapper> pendingCustomImpl;
165+
static std::unique_ptr<GAHttpClient> pendingCustomImpl;
166166
};
167167

168168
constexpr const char* GAHTTPApi::sdkErrorCategoryString(EGASdkErrorCategory value)

source/gameanalytics/GameAnalytics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ namespace gameanalytics
350350

351351
// ----------------------- INITIALIZE ---------------------- //
352352

353-
void GameAnalytics::configureHttpClient(std::unique_ptr<GAHttpWrapper> httpClient)
353+
void GameAnalytics::configureHttpClient(std::unique_ptr<GAHttpClient> httpClient)
354354
{
355355
if(_endThread)
356356
{

source/gameanalytics/Http/GAHttpCurl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace gameanalytics
66
{
7-
size_t writefunc(void *ptr, size_t size, size_t nmemb, GAHttpWrapper::Response *s)
7+
size_t writefunc(void *ptr, size_t size, size_t nmemb, GAHttpClient::Response *s)
88
{
99
if(!s || !ptr)
1010
{
@@ -28,7 +28,7 @@ namespace gameanalytics
2828
curl_global_cleanup();
2929
}
3030

31-
GAHttpWrapper::Response GAHttpCurl::sendRequest(std::string const& url, std::string const& auth, std::vector<uint8_t> const& payloadData, bool useGzip, void* userData)
31+
GAHttpClient::Response GAHttpCurl::sendRequest(std::string const& url, std::string const& auth, std::vector<uint8_t> const& payloadData, bool useGzip, void* userData)
3232
{
3333
CURL* curl = curl_easy_init();
3434
if (!curl)
@@ -38,7 +38,7 @@ namespace gameanalytics
3838

3939
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
4040

41-
GAHttpWrapper::Response response = {};
41+
GAHttpClient::Response response = {};
4242

4343
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
4444
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

source/gameanalytics/Http/GAHttpCurl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#pragma once
22

3-
#include "GameAnalytics/GAHttpWrapper.h"
3+
#include "GameAnalytics/GAHttpClient.h"
44
#include <curl/curl.h>
55

66
namespace gameanalytics
77
{
8-
class GAHttpCurl: public GAHttpWrapper
8+
class GAHttpCurl: public GAHttpClient
99
{
1010
virtual void initialize() override;
1111

test/GAHttpInterfaceTests.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
#include <gtest/gtest.h>
88

99
#include "GameAnalytics/GameAnalytics.h"
10-
#include "GameAnalytics/GAHttpWrapper.h"
10+
#include "GameAnalytics/GAHttpClient.h"
1111
#include "GAHTTPApi.h"
1212

1313
namespace
1414
{
1515

1616
// A mock HTTP implementation for testing
17-
class MockHttpClient : public gameanalytics::GAHttpWrapper
17+
class MockHttpClient : public gameanalytics::GAHttpClient
1818
{
1919
public:
2020
void initialize() override
@@ -58,22 +58,22 @@ class MockHttpClient : public gameanalytics::GAHttpWrapper
5858

5959
// -------- Response struct tests --------
6060

61-
TEST(GAHttpWrapperResponse, DefaultResponseHasNegativeCode)
61+
TEST(GAHttpClientResponse, DefaultResponseHasNegativeCode)
6262
{
63-
gameanalytics::GAHttpWrapper::Response response;
63+
gameanalytics::GAHttpClient::Response response;
6464
EXPECT_EQ(response.code, -1);
6565
EXPECT_TRUE(response.packet.empty());
6666
}
6767

68-
TEST(GAHttpWrapperResponse, ToStringReturnsEmptyForEmptyPacket)
68+
TEST(GAHttpClientResponse, ToStringReturnsEmptyForEmptyPacket)
6969
{
70-
gameanalytics::GAHttpWrapper::Response response;
70+
gameanalytics::GAHttpClient::Response response;
7171
EXPECT_TRUE(response.toString().empty());
7272
}
7373

74-
TEST(GAHttpWrapperResponse, ToStringReturnsPacketContent)
74+
TEST(GAHttpClientResponse, ToStringReturnsPacketContent)
7575
{
76-
gameanalytics::GAHttpWrapper::Response response;
76+
gameanalytics::GAHttpClient::Response response;
7777
std::string body = R"({"status":"ok"})";
7878
response.packet.assign(body.begin(), body.end());
7979
response.code = 200;
@@ -83,9 +83,9 @@ TEST(GAHttpWrapperResponse, ToStringReturnsPacketContent)
8383
EXPECT_EQ(result.size(), body.size());
8484
}
8585

86-
TEST(GAHttpWrapperResponse, ToStringHandlesBinaryData)
86+
TEST(GAHttpClientResponse, ToStringHandlesBinaryData)
8787
{
88-
gameanalytics::GAHttpWrapper::Response response;
88+
gameanalytics::GAHttpClient::Response response;
8989
response.packet = {0x00, 0x01, 0x02, 0xFF};
9090
response.code = 200;
9191

0 commit comments

Comments
 (0)