Skip to content

Commit 38ccf35

Browse files
committed
Json is now only sent if it changes
1 parent 71f18ed commit 38ccf35

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

AuroraGSI-RL/AuroraGSI.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "AuroraGSI.h"
33

44
//using std::placeholders::_1;
5-
BAKKESMOD_PLUGIN(AuroraGSI, "AuroraGSI", "0.0.1", PLUGINTYPE_THREADED)
5+
BAKKESMOD_PLUGIN(AuroraGSI, "AuroraGSI", "0.0.2", PLUGINTYPE_THREADED)
66

77
#pragma region Plugin Methods
88
void AuroraGSI::onLoad()
@@ -12,16 +12,23 @@ void AuroraGSI::onLoad()
1212

1313
void AuroraGSI::onUnload()
1414
{
15+
ok = false;
16+
cvarManager->log("false");
1517
}
1618
#pragma endregion
1719

1820
#pragma region Aurora
1921
void AuroraGSI::StartLoop() {
20-
for (;;) {
22+
while (ok) {
2123
gameWrapper->Execute(std::bind(&AuroraGSI::UpdateMatchState, this));
22-
SendToAurora(GameState.GetJson().dump());
24+
string newJson = GameState.GetJson().dump();
25+
if (Json != newJson) {
26+
Json = newJson;
27+
SendToAurora(newJson);
28+
}
2329
Sleep(100);
2430
}
31+
cvarManager->log("stop");
2532
}
2633

2734
void AuroraGSI::SendToAurora(std::string data)
@@ -31,7 +38,7 @@ void AuroraGSI::SendToAurora(std::string data)
3138
(void)request.send("POST", data, { "Content-Type: application/json" });
3239
}
3340
catch (...) {
34-
//ignore
41+
ok = false;
3542
}
3643
}
3744
#pragma endregion

AuroraGSI-RL/AuroraGSI.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@ class AuroraGSI : public BakkesMod::Plugin::BakkesModPlugin
99
public:
1010
virtual void onLoad();
1111
virtual void onUnload();
12-
1312
private:
1413
#pragma region Fields
1514
GameStateNode GameState;
15+
std::string Json;
16+
bool ok = true;
1617
#pragma endregion
1718

1819
#pragma region Aurora
1920
void StartLoop();
2021
void SendToAurora(std::string);
21-
ServerWrapper GetCurrentGameType();
2222
#pragma endregion
2323

2424
#pragma region Update States
2525
void UpdateMatchState();
2626
void UpdateState(ServerWrapper wrapper);
2727
void ResetStates();
28+
ServerWrapper GetCurrentGameType();
2829
#pragma endregion
2930
};

0 commit comments

Comments
 (0)