mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-29 18:27:12 +02:00
Rename msg::ClientSettings to msg::ClientInfo
This commit is contained in:
parent
e8bb8ecdba
commit
47f7291d4f
6 changed files with 24 additions and 23 deletions
|
@ -34,7 +34,7 @@
|
|||
#include "browseZeroConf/browse_mdns.hpp"
|
||||
#include "common/aixlog.hpp"
|
||||
#include "common/snap_exception.hpp"
|
||||
#include "message/client_settings.hpp"
|
||||
#include "message/client_info.hpp"
|
||||
#include "message/hello.hpp"
|
||||
#include "message/time.hpp"
|
||||
#include "time_provider.hpp"
|
||||
|
@ -163,13 +163,13 @@ void Controller::getNextMessage()
|
|||
{
|
||||
last_volume = volume;
|
||||
last_muted = muted;
|
||||
auto settings = std::make_shared<msg::ClientSettings>();
|
||||
settings->setVolume(static_cast<uint16_t>(volume * 100.));
|
||||
settings->setMuted(muted);
|
||||
clientConnection_->send(settings, [this](const boost::system::error_code& ec) {
|
||||
auto info = std::make_shared<msg::ClientInfo>();
|
||||
info->setVolume(static_cast<uint16_t>(volume * 100.));
|
||||
info->setMuted(muted);
|
||||
clientConnection_->send(info, [this](const boost::system::error_code& ec) {
|
||||
if (ec)
|
||||
{
|
||||
LOG(ERROR, LOG_TAG) << "Failed to send client settings, error: " << ec.message() << "\n";
|
||||
LOG(ERROR, LOG_TAG) << "Failed to send client info, error: " << ec.message() << "\n";
|
||||
reconnect();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#ifndef WASAPI_PLAYER_H
|
||||
#define WASAPI_PLAYER_H
|
||||
#include "client_settings.hpp"
|
||||
#include "player.hpp"
|
||||
#include <audiopolicy.h>
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#ifndef CLIENT_SETTINGS_H
|
||||
#define CLIENT_SETTINGS_H
|
||||
#ifndef CLIENT_INFO_H
|
||||
#define CLIENT_INFO_H
|
||||
|
||||
#include "json_message.hpp"
|
||||
|
||||
|
@ -25,16 +25,18 @@
|
|||
namespace msg
|
||||
{
|
||||
|
||||
class ClientSettings : public JsonMessage
|
||||
/// Client information sent from client to server
|
||||
/// Might also be used for sync stats and latency estimations
|
||||
class ClientInfo : public JsonMessage
|
||||
{
|
||||
public:
|
||||
ClientSettings() : JsonMessage(message_type::kClientSettings)
|
||||
ClientInfo() : JsonMessage(message_type::kClientInfo)
|
||||
{
|
||||
setVolume(100);
|
||||
setMuted(false);
|
||||
}
|
||||
|
||||
~ClientSettings() override = default;
|
||||
~ClientInfo() override = default;
|
||||
|
||||
uint16_t getVolume()
|
||||
{
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef MESSAGE_FACTORY_HPP
|
||||
#define MESSAGE_FACTORY_HPP
|
||||
|
||||
#include "client_settings.hpp"
|
||||
#include "client_info.hpp"
|
||||
#include "codec_header.hpp"
|
||||
#include "hello.hpp"
|
||||
#include "pcm_chunk.hpp"
|
||||
|
@ -82,8 +82,8 @@ static std::unique_ptr<BaseMessage> createMessage(const BaseMessage& base_messag
|
|||
// this is kind of cheated to safe the convertion from WireChunk to PcmChunk
|
||||
// the user of the factory must be aware that a PcmChunk will be created
|
||||
return createMessage<PcmChunk>(base_message, buffer);
|
||||
case kClientSettings:
|
||||
return createMessage<ClientSettings>(base_message, buffer);
|
||||
case kClientInfo:
|
||||
return createMessage<ClientInfo>(base_message, buffer);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -60,10 +60,10 @@ enum message_type
|
|||
kTime = 4,
|
||||
kHello = 5,
|
||||
kStreamTags = 6,
|
||||
kClientSettings = 7,
|
||||
kClientInfo = 7,
|
||||
|
||||
kFirst = kBase,
|
||||
kLast = kClientSettings
|
||||
kLast = kClientInfo
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "stream_server.hpp"
|
||||
#include "common/aixlog.hpp"
|
||||
#include "config.hpp"
|
||||
#include "message/client_settings.hpp"
|
||||
#include "message/client_info.hpp"
|
||||
#include "message/hello.hpp"
|
||||
#include "message/stream_tags.hpp"
|
||||
#include "message/time.hpp"
|
||||
|
@ -635,7 +635,7 @@ void StreamServer::onMessageReceived(StreamSession* streamSession, const msg::Ba
|
|||
client->connected = true;
|
||||
}
|
||||
}
|
||||
else if (baseMessage.type == message_type::kClientSettings)
|
||||
else if (baseMessage.type == message_type::kClientInfo)
|
||||
{
|
||||
ClientInfoPtr clientInfo = Config::instance().getClientInfo(streamSession->clientId);
|
||||
if (clientInfo == nullptr)
|
||||
|
@ -643,11 +643,11 @@ void StreamServer::onMessageReceived(StreamSession* streamSession, const msg::Ba
|
|||
LOG(ERROR) << "client not found: " << streamSession->clientId << "\n";
|
||||
return;
|
||||
}
|
||||
msg::ClientSettings settingsMsg;
|
||||
settingsMsg.deserialize(baseMessage, buffer);
|
||||
msg::ClientInfo infoMsg;
|
||||
infoMsg.deserialize(baseMessage, buffer);
|
||||
|
||||
clientInfo->config.volume.percent = settingsMsg.getVolume();
|
||||
clientInfo->config.volume.muted = settingsMsg.isMuted();
|
||||
clientInfo->config.volume.percent = infoMsg.getVolume();
|
||||
clientInfo->config.volume.muted = infoMsg.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());
|
||||
|
|
Loading…
Add table
Reference in a new issue