fixed loading of client config

This commit is contained in:
badaix 2016-03-21 22:57:22 +01:00
parent a9a9443563
commit 1f177e5119
2 changed files with 13 additions and 2 deletions

View file

@ -55,9 +55,16 @@ Config::Config()
{ {
ClientInfoPtr client = make_shared<ClientInfo>(); ClientInfoPtr client = make_shared<ClientInfo>();
client->fromJson(*it); client->fromJson(*it);
if (client->host.mac.empty())
continue;
for (const auto& c: clients)
{
if (c->host.mac == client->host.mac)
continue;
}
client->connected = false; client->connected = false;
clients.push_back(client); clients.push_back(client);
// logO << "Client:\n" << std::setw(4) << client->toJson() << '\n';
} }
} }
} }

View file

@ -209,7 +209,9 @@ struct ClientInfo
void fromJson(const json& j) void fromJson(const json& j)
{ {
if (j.count("host") && !j["host"].is_string()) if (j.count("host") && !j["host"].is_string())
{
host.fromJson(j["host"]); host.fromJson(j["host"]);
}
else else
{ {
host.ip = jGet<std::string>(j, "IP", ""); host.ip = jGet<std::string>(j, "IP", "");
@ -223,7 +225,9 @@ struct ClientInfo
snapclient.version = jGet<std::string>(j, "version", ""); snapclient.version = jGet<std::string>(j, "version", "");
if (j.count("config")) if (j.count("config"))
host.fromJson(j["config"]); {
config.fromJson(j["config"]);
}
else else
{ {
config.name = trim_copy(jGet<std::string>(j, "name", "")); config.name = trim_copy(jGet<std::string>(j, "name", ""));