From 9192dca4e668b60193e04e2f50262ee1d71382d1 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Thu, 25 Apr 2024 22:27:28 -0500 Subject: [PATCH] address feedback --- dChatServer/ChatWebApi.cpp | 16 +++++++--------- dChatServer/ChatWebApi.h | 2 +- dChatServer/PlayerContainer.cpp | 4 ++-- dChatServer/PlayerContainer.h | 4 +--- dCommon/json.h | 10 ++++++++++ docs/ChatWebAPI.yaml | 2 ++ 6 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 dCommon/json.h diff --git a/dChatServer/ChatWebApi.cpp b/dChatServer/ChatWebApi.cpp index 0ac185d8..4e4d79a0 100644 --- a/dChatServer/ChatWebApi.cpp +++ b/dChatServer/ChatWebApi.cpp @@ -1,7 +1,7 @@ -#include -#include - #include "ChatWebApi.h" + +#include + #include "dCommonVars.h" #include "eConnectionType.h" #include "eChatMessageType.h" @@ -9,8 +9,8 @@ #include "dServer.h" #include "PlayerContainer.h" #include "dConfig.h" - -using json = nlohmann::json; +#include "httplib.h" +#include "json.h" namespace { httplib::Server m_APIServer; @@ -86,8 +86,6 @@ void ChatWebApi::Listen(const uint32_t port) { }; void ChatWebApi::Stop(){ - if (Game::config->GetValue("enable_chat_web_api") == "1") { - LOG("Stopping Chat Web API server..."); - m_APIServer.stop(); - } + LOG("Stopping Chat Web API server..."); + m_APIServer.stop(); } diff --git a/dChatServer/ChatWebApi.h b/dChatServer/ChatWebApi.h index 420a4087..5b3c68f8 100644 --- a/dChatServer/ChatWebApi.h +++ b/dChatServer/ChatWebApi.h @@ -1,4 +1,4 @@ -#include "httplib.h" +#include namespace ChatWebApi { void Listen(const uint32_t port); diff --git a/dChatServer/PlayerContainer.cpp b/dChatServer/PlayerContainer.cpp index 443f38a0..be122542 100644 --- a/dChatServer/PlayerContainer.cpp +++ b/dChatServer/PlayerContainer.cpp @@ -1,7 +1,8 @@ +#include "PlayerContainer.h" + #include #include -#include "PlayerContainer.h" #include "dNetCommon.h" #include "Game.h" #include "Logger.h" @@ -14,7 +15,6 @@ #include "dConfig.h" #include "eChatMessageType.h" - const json PlayerData::to_json() const { json data; data["id"] = this->playerID; diff --git a/dChatServer/PlayerContainer.h b/dChatServer/PlayerContainer.h index 8a094856..55fb2997 100644 --- a/dChatServer/PlayerContainer.h +++ b/dChatServer/PlayerContainer.h @@ -6,9 +6,7 @@ #include "Game.h" #include "dServer.h" #include - -#include -using json = nlohmann::json; +#include "json.h" enum class eGameMasterLevel : uint8_t; diff --git a/dCommon/json.h b/dCommon/json.h new file mode 100644 index 00000000..0ce06dc7 --- /dev/null +++ b/dCommon/json.h @@ -0,0 +1,10 @@ +#ifndef __JSON__H__ +#define __JSON__H__ + +#include "nlohmann/json.hpp" + +namespace { + using json = nlohmann::json; +} + +#endif // !__JSON__H__ \ No newline at end of file diff --git a/docs/ChatWebAPI.yaml b/docs/ChatWebAPI.yaml index 815ddd16..9c070cbb 100644 --- a/docs/ChatWebAPI.yaml +++ b/docs/ChatWebAPI.yaml @@ -48,6 +48,7 @@ paths: get: tags: - user + summary: Get all online Players responses: "200": description: Successful operation @@ -64,6 +65,7 @@ paths: get: tags: - user + summary: Get all active Teams responses: "200": description: Successful operation