Rename msg::ClientSettings to msg::ClientInfo

This commit is contained in:
badaix 2020-04-30 13:33:02 +02:00
parent e8bb8ecdba
commit 47f7291d4f
6 changed files with 24 additions and 23 deletions

View file

@ -34,7 +34,7 @@
#include "browseZeroConf/browse_mdns.hpp" #include "browseZeroConf/browse_mdns.hpp"
#include "common/aixlog.hpp" #include "common/aixlog.hpp"
#include "common/snap_exception.hpp" #include "common/snap_exception.hpp"
#include "message/client_settings.hpp" #include "message/client_info.hpp"
#include "message/hello.hpp" #include "message/hello.hpp"
#include "message/time.hpp" #include "message/time.hpp"
#include "time_provider.hpp" #include "time_provider.hpp"
@ -163,13 +163,13 @@ void Controller::getNextMessage()
{ {
last_volume = volume; last_volume = volume;
last_muted = muted; last_muted = muted;
auto settings = std::make_shared<msg::ClientSettings>(); auto info = std::make_shared<msg::ClientInfo>();
settings->setVolume(static_cast<uint16_t>(volume * 100.)); info->setVolume(static_cast<uint16_t>(volume * 100.));
settings->setMuted(muted); info->setMuted(muted);
clientConnection_->send(settings, [this](const boost::system::error_code& ec) { clientConnection_->send(info, [this](const boost::system::error_code& ec) {
if (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(); reconnect();
return; return;
} }

View file

@ -18,7 +18,6 @@
#ifndef WASAPI_PLAYER_H #ifndef WASAPI_PLAYER_H
#define WASAPI_PLAYER_H #define WASAPI_PLAYER_H
#include "client_settings.hpp"
#include "player.hpp" #include "player.hpp"
#include <audiopolicy.h> #include <audiopolicy.h>

View file

@ -16,8 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
***/ ***/
#ifndef CLIENT_SETTINGS_H #ifndef CLIENT_INFO_H
#define CLIENT_SETTINGS_H #define CLIENT_INFO_H
#include "json_message.hpp" #include "json_message.hpp"
@ -25,16 +25,18 @@
namespace msg 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: public:
ClientSettings() : JsonMessage(message_type::kClientSettings) ClientInfo() : JsonMessage(message_type::kClientInfo)
{ {
setVolume(100); setVolume(100);
setMuted(false); setMuted(false);
} }
~ClientSettings() override = default; ~ClientInfo() override = default;
uint16_t getVolume() uint16_t getVolume()
{ {

View file

@ -19,7 +19,7 @@
#ifndef MESSAGE_FACTORY_HPP #ifndef MESSAGE_FACTORY_HPP
#define MESSAGE_FACTORY_HPP #define MESSAGE_FACTORY_HPP
#include "client_settings.hpp" #include "client_info.hpp"
#include "codec_header.hpp" #include "codec_header.hpp"
#include "hello.hpp" #include "hello.hpp"
#include "pcm_chunk.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 // 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 // the user of the factory must be aware that a PcmChunk will be created
return createMessage<PcmChunk>(base_message, buffer); return createMessage<PcmChunk>(base_message, buffer);
case kClientSettings: case kClientInfo:
return createMessage<ClientSettings>(base_message, buffer); return createMessage<ClientInfo>(base_message, buffer);
default: default:
return nullptr; return nullptr;
} }

View file

@ -60,10 +60,10 @@ enum message_type
kTime = 4, kTime = 4,
kHello = 5, kHello = 5,
kStreamTags = 6, kStreamTags = 6,
kClientSettings = 7, kClientInfo = 7,
kFirst = kBase, kFirst = kBase,
kLast = kClientSettings kLast = kClientInfo
}; };

View file

@ -19,7 +19,7 @@
#include "stream_server.hpp" #include "stream_server.hpp"
#include "common/aixlog.hpp" #include "common/aixlog.hpp"
#include "config.hpp" #include "config.hpp"
#include "message/client_settings.hpp" #include "message/client_info.hpp"
#include "message/hello.hpp" #include "message/hello.hpp"
#include "message/stream_tags.hpp" #include "message/stream_tags.hpp"
#include "message/time.hpp" #include "message/time.hpp"
@ -635,7 +635,7 @@ void StreamServer::onMessageReceived(StreamSession* streamSession, const msg::Ba
client->connected = true; client->connected = true;
} }
} }
else if (baseMessage.type == message_type::kClientSettings) else if (baseMessage.type == message_type::kClientInfo)
{ {
ClientInfoPtr clientInfo = Config::instance().getClientInfo(streamSession->clientId); ClientInfoPtr clientInfo = Config::instance().getClientInfo(streamSession->clientId);
if (clientInfo == nullptr) if (clientInfo == nullptr)
@ -643,11 +643,11 @@ void StreamServer::onMessageReceived(StreamSession* streamSession, const msg::Ba
LOG(ERROR) << "client not found: " << streamSession->clientId << "\n"; LOG(ERROR) << "client not found: " << streamSession->clientId << "\n";
return; return;
} }
msg::ClientSettings settingsMsg; msg::ClientInfo infoMsg;
settingsMsg.deserialize(baseMessage, buffer); infoMsg.deserialize(baseMessage, buffer);
clientInfo->config.volume.percent = settingsMsg.getVolume(); clientInfo->config.volume.percent = infoMsg.getVolume();
clientInfo->config.volume.muted = settingsMsg.isMuted(); clientInfo->config.volume.muted = infoMsg.isMuted();
jsonrpcpp::notification_ptr notification = make_shared<jsonrpcpp::Notification>( jsonrpcpp::notification_ptr notification = make_shared<jsonrpcpp::Notification>(
"Client.OnVolumeChanged", jsonrpcpp::Parameter("id", streamSession->clientId, "volume", clientInfo->config.volume.toJson())); "Client.OnVolumeChanged", jsonrpcpp::Parameter("id", streamSession->clientId, "volume", clientInfo->config.volume.toJson()));
controlServer_->send(notification->to_json().dump()); controlServer_->send(notification->to_json().dump());