mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-10 07:36:41 +02:00
Server reads and propagates client volume changes
This commit is contained in:
parent
0996c04dca
commit
b5854df960
1 changed files with 18 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "stream_server.hpp"
|
||||
#include "common/aixlog.hpp"
|
||||
#include "config.hpp"
|
||||
#include "message/client_settings.hpp"
|
||||
#include "message/hello.hpp"
|
||||
#include "message/stream_tags.hpp"
|
||||
#include "message/time.hpp"
|
||||
|
@ -634,6 +635,23 @@ void StreamServer::onMessageReceived(StreamSession* streamSession, const msg::Ba
|
|||
client->connected = true;
|
||||
}
|
||||
}
|
||||
else if (baseMessage.type == message_type::kClientSettings)
|
||||
{
|
||||
ClientInfoPtr clientInfo = Config::instance().getClientInfo(streamSession->clientId);
|
||||
if (clientInfo == nullptr)
|
||||
{
|
||||
LOG(ERROR) << "client not found: " << streamSession->clientId << "\n";
|
||||
return;
|
||||
}
|
||||
msg::ClientSettings settingsMsg;
|
||||
settingsMsg.deserialize(baseMessage, buffer);
|
||||
|
||||
clientInfo->config.volume.percent = settingsMsg.getVolume();
|
||||
clientInfo->config.volume.muted = settingsMsg.isMuted();
|
||||
jsonrpcpp::notification_ptr notification = make_shared<jsonrpcpp::Notification>(
|
||||
"Client.OnVolumeChanged", jsonrpcpp::Parameter("id", streamSession->clientId, "volume", clientInfo->config.volume.toJson()));
|
||||
controlServer_->send(notification->to_json().dump());
|
||||
}
|
||||
else if (baseMessage.type == message_type::kHello)
|
||||
{
|
||||
msg::Hello helloMsg;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue