mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-30 06:39:35 +02:00
delete client
This commit is contained in:
parent
3e8842b941
commit
252cda188a
3 changed files with 18 additions and 0 deletions
|
@ -91,3 +91,8 @@ json Config::getClientInfos() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Config::remove(ClientInfoPtr client)
|
||||||
|
{
|
||||||
|
clients.erase(std::remove(clients.begin(), clients.end(), client), clients.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientInfoPtr getClientInfo(const std::string& mac, bool add = true);
|
ClientInfoPtr getClientInfo(const std::string& mac, bool add = true);
|
||||||
|
void remove(ClientInfoPtr client);
|
||||||
|
|
||||||
std::vector<ClientInfoPtr> clients;
|
std::vector<ClientInfoPtr> clients;
|
||||||
json getClientInfos() const;
|
json getClientInfos() const;
|
||||||
|
|
|
@ -161,6 +161,18 @@ void StreamServer::onMessageReceived(ControlSession* controlSession, const std::
|
||||||
{"clients", jClient}
|
{"clients", jClient}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
else if (request.method == "System.DeleteClient")
|
||||||
|
{
|
||||||
|
clientInfo = Config::instance().getClientInfo(request.getParam("client").get<string>(), false);
|
||||||
|
if (clientInfo == nullptr)
|
||||||
|
throw JsonInternalErrorException("Client not found", request.id);
|
||||||
|
response = clientInfo->macAddress;
|
||||||
|
Config::instance().remove(clientInfo);
|
||||||
|
Config::instance().save();
|
||||||
|
json notification = JsonNotification::getJson("Client.OnDelete", clientInfo->toJson());
|
||||||
|
controlServer_->send(notification.dump(), controlSession);
|
||||||
|
clientInfo = nullptr;
|
||||||
|
}
|
||||||
else if (request.method == "Client.SetVolume")
|
else if (request.method == "Client.SetVolume")
|
||||||
{
|
{
|
||||||
clientInfo->volume.percent = request.getParam<uint16_t>("volume", 0, 100);
|
clientInfo->volume.percent = request.getParam<uint16_t>("volume", 0, 100);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue