mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Master server query code improvements
* Improved error messages. * Fixed bug where status was not checked to determine what error message to return.
This commit is contained in:
parent
b965e04dd4
commit
8b227c90d8
@ -78,7 +78,7 @@ vector<NetGameServer_t> CPylon::GetServerList(string& svOutMessage) const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
svOutMessage = string("Unknown error with status: ") + std::to_string(status);
|
svOutMessage = fmt::format("Unknown error with status: {:d}", status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,17 +96,17 @@ vector<NetGameServer_t> CPylon::GetServerList(string& svOutMessage) const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
svOutMessage = string("Failed HTTP request: ") + std::to_string(status);
|
svOutMessage = fmt::format("Server list error: {:d}", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return vslList;
|
return vslList;
|
||||||
}
|
}
|
||||||
|
|
||||||
svOutMessage = string("Failed HTTP request: ") + std::to_string(status);
|
svOutMessage = fmt::format("Failed comp-server query: {:d}", status);
|
||||||
return vslList;
|
return vslList;
|
||||||
}
|
}
|
||||||
|
|
||||||
svOutMessage = "Failed to reach comp-server: connection timed-out";
|
svOutMessage = fmt::format("Failed to reach comp-server: {:s}", "connection timed-out");
|
||||||
return vslList;
|
return vslList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,37 +198,38 @@ bool CPylon::GetServerByToken(NetGameServer_t& slOutServer, string& svOutMessage
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
svOutMessage = string("Unknown error with status: ") + std::to_string(status);
|
svOutMessage = fmt::format("Unknown error with status: {:d}", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
slOutServer = NetGameServer_t{};
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!svResponseBuf.empty())
|
if (status)
|
||||||
{
|
{
|
||||||
nlohmann::json jsResultBody = nlohmann::json::parse(svResponseBuf);
|
if (!svResponseBuf.empty())
|
||||||
|
{
|
||||||
|
nlohmann::json jsResultBody = nlohmann::json::parse(svResponseBuf);
|
||||||
|
|
||||||
if (jsResultBody["error"].is_string())
|
if (jsResultBody["error"].is_string())
|
||||||
{
|
{
|
||||||
svOutMessage = jsResultBody["error"].get<string>();
|
svOutMessage = jsResultBody["error"].get<string>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
svOutMessage = string("Server not found: ") + std::to_string(status);
|
svOutMessage = fmt::format("Server not found: {:d}", status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
svOutMessage = fmt::format("Failed comp-server query: {:d}", status);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
svOutMessage = string("Failed HTTP request: ") + std::to_string(status);
|
svOutMessage = fmt::format("Failed to reach comp-server: {:s}", "connection timed-out");
|
||||||
return false;
|
|
||||||
|
|
||||||
svOutMessage = "Failed to reach comp-server: connection timed-out";
|
|
||||||
slOutServer = NetGameServer_t{};
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,7 +310,8 @@ bool CPylon::PostServerHost(string& svOutMessage, string& svOutToken, const NetG
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
svOutToken = string();
|
svOutMessage = fmt::format("Invalid response with status: {:d}", status);
|
||||||
|
svOutToken.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -322,36 +324,39 @@ bool CPylon::PostServerHost(string& svOutMessage, string& svOutToken, const NetG
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
svOutMessage = string("Unknown error with status: ") + std::to_string(status);
|
svOutMessage = fmt::format("Unknown error with status: {:d}", status);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!svResponseBuf.empty())
|
if (status)
|
||||||
{
|
{
|
||||||
nlohmann::json jsResultBody = nlohmann::json::parse(svResponseBuf);
|
if (!svResponseBuf.empty())
|
||||||
|
{
|
||||||
|
nlohmann::json jsResultBody = nlohmann::json::parse(svResponseBuf);
|
||||||
|
|
||||||
if (jsResultBody["error"].is_string())
|
if (jsResultBody["error"].is_string())
|
||||||
{
|
{
|
||||||
svOutMessage = jsResultBody["error"].get<string>();
|
svOutMessage = jsResultBody["error"].get<string>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
svOutMessage = string("Failed HTTP request: ") + std::to_string(status);
|
svOutMessage = fmt::format("Server host error: {:d}", status);
|
||||||
|
}
|
||||||
|
|
||||||
|
svOutToken.clear();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
svOutToken = string();
|
svOutMessage = fmt::format("Failed comp-server query: {:d}", status);
|
||||||
|
svOutToken.clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
svOutToken = string();
|
svOutMessage = fmt::format("Failed to reach comp-server: {:s}", "connection timed-out");
|
||||||
svOutMessage = string("Failed HTTP request: ") + std::to_string(status);
|
svOutToken.clear();
|
||||||
return false;
|
|
||||||
|
|
||||||
svOutToken = string();
|
|
||||||
svOutMessage = "Failed to reach comp-server: connection timed-out";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user