基本通信测试通过。

This commit is contained in:
2026-03-10 11:51:02 +08:00
commit b361eb3f88
15 changed files with 690 additions and 0 deletions

62
bf.config.cpp Normal file
View File

@@ -0,0 +1,62 @@
#include "bf.config.h"
#include <fstream>
#include <nlohmann/json.hpp>
#include "bf.util.h"
bool BF_Config::parseConfig(const std::string& file)
{
try {
std::ifstream ifs(file);
if (!ifs.is_open()) {
gLogger->error("Failed to open config file: {}", file);
return false;
}
nlohmann::json configJson;
ifs >> configJson;
if (!configJson.contains("baseUrl")) {
gLogger->error("Missing 'baseUrl' field in config file");
return false;
}
baseUrl = configJson["baseUrl"];
if (!configJson.contains("appId")) {
gLogger->error("Missing 'appId' field in config file");
return false;
}
appId = configJson["appId"];
if (!configJson.contains("appKey")) {
gLogger->error("Missing 'appKey' field in config file");
return false;
}
appKey = configJson["appKey"];
if (!configJson.contains("appSecret")) {
gLogger->error("Missing 'appSecret' field in config file");
return false;
}
appSecret = configJson["appSecret"];
if (configJson.contains("type")) {
int typeValue = configJson["type"];
if (typeValue == BFT_AI) {
type = BFT_AI;
} else {
type = BFT_COMMON;
}
}
gLogger->info("Config loaded successfully from: {}", file);
return true;
} catch (const nlohmann::json::exception& e) {
gLogger->error("JSON parsing error: {}", e.what());
return false;
} catch (const std::exception& e) {
gLogger->error("Failed to parse config: {}", e.what());
return false;
}
}