diff --git a/src/plugins/server/Constants.h b/src/plugins/server/Constants.h index dfa36fb4f..8734d5337 100644 --- a/src/plugins/server/Constants.h +++ b/src/plugins/server/Constants.h @@ -113,6 +113,7 @@ namespace key { static const std::string relative = "relative"; static const std::string password = "password"; static const std::string authenticated = "authenticated"; + static const std::string environment = "environment"; static const std::string playlist_id = "playlist_id"; static const std::string playlist_name = "playlist_name"; static const std::string subquery = "subquery"; @@ -121,6 +122,8 @@ namespace key { static const std::string sort_orders = "sort_orders"; static const std::string predicate_category = "predicate_category"; static const std::string predicate_id = "predicate_id"; + static const std::string sdk_version = "sdk_version"; + static const std::string api_version = "api_version"; } namespace value { @@ -192,4 +195,6 @@ static auto REPEAT_MODE_TO_STRING = makeBimap jsonToIntArray(json& arr) { }); } +static json getEnvironment(Context& context) { + return { + { prefs::http_server_enabled, context.prefs->GetBool(prefs::http_server_enabled.c_str()) }, + { prefs::http_server_port, context.prefs->GetInt(prefs::http_server_port.c_str()) }, + { key::sdk_version, musik::core::sdk::SdkVersion }, + { key::api_version, ApiVersion } + }; +} + /* IMPLEMENTATION */ WebSocketServer::WebSocketServer(Context& context) @@ -215,9 +224,10 @@ void WebSocketServer::HandleAuthentication(connection_hdl connection, json& requ this->connections[connection] = true; /* mark as authed */ this->RespondWithOptions( - connection, - request, - json({ { key::authenticated, true } })); + connection, request, json({ + { key::authenticated, true }, + { key::environment, getEnvironment(context) } + })); return; } @@ -871,10 +881,7 @@ void WebSocketServer::RespondWithPlayTracksByCategory(connection_hdl connection, } void WebSocketServer::RespondWithEnvironment(connection_hdl connection, json& request) { - this->RespondWithOptions(connection, request, { - { prefs::http_server_enabled, context.prefs->GetBool(prefs::http_server_enabled.c_str()) }, - { prefs::http_server_port, context.prefs->GetInt(prefs::http_server_port.c_str()) } - }); + this->RespondWithOptions(connection, request, getEnvironment(context)); } void WebSocketServer::RespondWithCurrentTime(connection_hdl connection, json& request) {