Skip to content

Commit 95a99bd

Browse files
committed
set player callbacks
1 parent 4d3e304 commit 95a99bd

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

source/gameanalytics/Server/GACustomFields.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,17 @@ namespace gameanalytics
4545
json j = serializeCustomFields(*this);
4646
return j.dump();
4747
}
48+
49+
void CustomFields::merge(CustomFields const& other)
50+
{
51+
for(auto& [key, val]: other.fields)
52+
{
53+
fields[key] = val;
54+
}
55+
}
56+
57+
bool CustomFields::checkSize()
58+
{
59+
60+
}
4861
}

source/gameanalytics/Server/GACustomFields.h

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

33
#include "GameAnalytics/GATypes.h"
4+
#include <variant>
45

56
namespace gameanalytics
67
{
@@ -20,6 +21,8 @@ namespace gameanalytics
2021
std::variant<int64_t, double, std::string, bool> value;
2122
};
2223

24+
static constexpr int NUM_MAX_CUSTOM_FIELDS = 50;
25+
2326
std::unordered_map<std::string, Value> fields;
2427

2528
inline bool isEmpty() const { return fields.empty(); }
@@ -31,6 +34,10 @@ namespace gameanalytics
3134
void setValue(std::string const& key, std::string const& val);
3235
void setValue(std::string const& key, bool val);
3336

37+
void merge(CustomFields const& other);
38+
39+
bool checkSize() const;
40+
3441
template<typename T>
3542
T getValue(std::string const& key, T const& defaultValue)
3643
{

source/gameanalytics/Server/GAServer.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@
1212

1313
namespace gameanalytics
1414
{
15-
GameAnalyticsServer::GameAnalyticsServer(std::string const& serverId, std::string const& extServerId, std::string const& build):
16-
_playerDatabase(std::make_shared<PlayerDatabase>())
15+
GameAnalyticsServer::GameAnalyticsServer(std::string const& serverId, std::string const& extServerId, std::string const& build, int numPlayersHint):
16+
_playerDatabase(std::make_shared<PlayerDatabase>(numPlayersHint))
1717
{
1818
GameAnalytics::configureUserId(serverId);
1919
GameAnalytics::configureBuild(build);
2020
GameAnalytics::configureExternalUserId(extServerId);
2121
}
2222

23+
void GameAnalyticsServer::setPlayerCallbacks(std::shared_ptr<PlayerCallbacks> callbacks)
24+
{
25+
_playerCallbacks = callbacks;
26+
}
27+
2328
bool GameAnalyticsServer::isExistingPlayer(std::string const& uid) const
2429
{
2530
return _playerDatabase->playerExists(uid);
@@ -181,7 +186,7 @@ namespace gameanalytics
181186
json eventDict = PlayerDatabase::getPlayerAnnotations(player);
182187

183188
eventDict["category"] = events::GAEvents::CategorySessionEnd;
184-
eventDict["length"] = player.currentSessionPlaytime();
189+
eventDict["length"] = player.getLastSessionLength();
185190

186191
events::GAEvents::getInstance().addEventToStore(eventDict);
187192

source/gameanalytics/Server/GAServer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ namespace gameanalytics
2121

2222
public:
2323

24-
GameAnalyticsServer(std::string const& serverId, std::string const& serverName, std::string const& build);
24+
GameAnalyticsServer(std::string const& serverId, std::string const& serverName, std::string const& build, int numPlayersHint = -1);
2525

26-
void setAvailableCustomDimensions();
2726
void setPlayerCallbacks(std::shared_ptr<PlayerCallbacks> callbacks);
2827

2928
bool isExistingPlayer(std::string const& userId) const;

0 commit comments

Comments
 (0)