Skip to content

Commit

Permalink
Merge pull request #6 from ArkServerApi/major-update-8-may
Browse files Browse the repository at this point in the history
Change messaging manager error for a warn, bump version to 1.16, add …
  • Loading branch information
Pelayori authored May 8, 2024
2 parents 45c64d4 + ee4c464 commit 3effd0f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion AsaApi/Core/Private/Ark/ApiUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ namespace AsaApi
{
TArray<FString> parsedName;
it->first.ParseIntoArray(parsedName, L"\\", true);
Log::GetLog()->error("Custom messaging error for '{}', using normal messaging. Reason: {}", parsedName.Last().ToString(), error.value());
Log::GetLog()->warn("Custom messaging error for '{}', using normal messaging. Reason: {}", parsedName.Last().ToString(), error.value());
it = messaging_managers_.erase(it);
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion AsaApi/Core/Private/Ark/ArkBaseApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace API
{
constexpr float api_version = 1.15f;
constexpr float api_version = 1.16f;

ArkBaseApi::ArkBaseApi()
: commands_(std::make_unique<AsaApi::Commands>()),
Expand Down
2 changes: 1 addition & 1 deletion AsaApi/Core/Private/Ark/ArkBaseApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace API
std::unique_ptr<AsaApi::IHooks>& GetHooks() override;
std::unique_ptr<AsaApi::IApiUtils>& GetApiUtils() override;

private:
nlohmann::json GetConfig();
private:
bool DownloadCacheFiles(const std::filesystem::path downloadFile, const std::filesystem::path localFile);

// Callbacks
Expand Down
31 changes: 22 additions & 9 deletions AsaApi/Core/Private/Tools/Requests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include <mutex>

#include "json.hpp"

#include "fstream"
#include "Poco/StreamCopier.h"
#include "Poco/URI.h"
Expand All @@ -29,6 +31,7 @@
#include "Poco/Net/HTTPSClientSession.h"
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h"
#include "../Ark/ArkBaseApi.h"

namespace API
{
Expand Down Expand Up @@ -58,7 +61,9 @@ namespace API
Requests::Requests()
: pimpl{ std::make_unique<impl>() }
{

const nlohmann::json config = dynamic_cast<ArkBaseApi&>(*game_api).GetConfig();
suppress_errors = config.value("SuppressHttpErrors", false);

Poco::Net::initializeSSL();
Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> ptrCert = new Poco::Net::RejectCertificateHandler(false);

Expand Down Expand Up @@ -155,7 +160,8 @@ namespace API
}
catch (const Poco::Exception& exc)
{
Log::GetLog()->error(exc.displayText());
if (!suppress_errors)
Log::GetLog()->error(exc.displayText());
}

const bool success = (int)response.getStatus() >= 200
Expand Down Expand Up @@ -193,7 +199,8 @@ namespace API
}
catch (const Poco::Exception& exc)
{
Log::GetLog()->error(exc.displayText());
if (!suppress_errors)
Log::GetLog()->error(exc.displayText());
}

const bool success = (int)response.getStatus() >= 200
Expand Down Expand Up @@ -231,7 +238,8 @@ namespace API
}
catch (const Poco::Exception& exc)
{
Log::GetLog()->error(exc.displayText());
if (!suppress_errors)
Log::GetLog()->error(exc.displayText());
}

const bool success = (int)response.getStatus() >= 200
Expand Down Expand Up @@ -285,7 +293,8 @@ namespace API
}
catch (const Poco::Exception& exc)
{
Log::GetLog()->error(exc.displayText());
if (!suppress_errors)
Log::GetLog()->error(exc.displayText());
}

const bool success = (int)response.getStatus() >= 200
Expand Down Expand Up @@ -323,7 +332,8 @@ namespace API
}
catch (const Poco::Exception& exc)
{
Log::GetLog()->error(exc.displayText());
if (!suppress_errors)
Log::GetLog()->error(exc.displayText());
}

const bool success = (int)response.getStatus() >= 200
Expand Down Expand Up @@ -361,7 +371,8 @@ namespace API
}
catch (const Poco::Exception& exc)
{
Log::GetLog()->error(exc.displayText());
if (!suppress_errors)
Log::GetLog()->error(exc.displayText());
}

const bool success = (int)response.getStatus() >= 200
Expand Down Expand Up @@ -394,7 +405,8 @@ namespace API
}
catch (const Poco::Exception& exc)
{
Log::GetLog()->error(exc.displayText());
if (!suppress_errors)
Log::GetLog()->error(exc.displayText());
}

const bool success = (int)response.getStatus() >= 200
Expand Down Expand Up @@ -426,7 +438,8 @@ namespace API
}
catch (const Poco::Exception& exc)
{
Log::GetLog()->error(exc.displayText());
if (!suppress_errors)
Log::GetLog()->error(exc.displayText());
}

Result.statusCode = (int)response.getStatus();
Expand Down
1 change: 1 addition & 0 deletions AsaApi/Core/Public/Requests.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,6 @@ namespace API
private:
class impl;
std::unique_ptr<impl> pimpl;
bool suppress_errors = false;
};
} // namespace API
3 changes: 2 additions & 1 deletion Configs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"AutomaticCacheDownload": {
"Enable": true,
"DownloadCacheURL": "https://cdn.pelayori.com/cache/"
}
},
"SuppressHttpErrors": false
}
}

0 comments on commit 3effd0f

Please sign in to comment.