Changed to get tracklist from CMS

This commit is contained in:
Henry Winkel
2024-03-14 18:28:43 +01:00
parent fb6b8f6178
commit 913cef4342

View File

@@ -11,6 +11,7 @@
#include "SimCore/UtilFunctions.hpp"
#include "WHISPER/InternalUDPListener.hpp"
#include "WHISPER/Messages/Message.hpp"
#include "WHISPER/Messages/stringData.hpp"
#include "crossguid/guid.hpp"
#include "ixwebsocket/IXConnectionState.h"
#include "ixwebsocket/IXWebSocket.h"
@@ -141,7 +142,7 @@ namespace SimControl {
void SimControl::HandleBroadcastMessage(std::string msg)
{
LOG_S(INFO)<<msg;
// LOG_S(INFO)<<msg;
auto track = SimCore::SimTrack::unpack(msg);
if (track != nullptr)
@@ -489,7 +490,7 @@ namespace SimControl {
{
return;
}
IP = cmsPod->IP;
IP = cmsPod->IP;
LOG_S(INFO)<<"PODS Info: " <<cmsPod->IP;
@@ -502,25 +503,30 @@ namespace SimControl {
client.disconnect();
if (response != "NULL")
{
auto update = SimCore::TracklistUpdate::unpack(WHISPER::Message(response));
if(update == nullptr)
{
LOG_S(INFO)<<"no update received";
return;
}
try
{
LOG_S(INFO)<<"raw data"<< response;
auto message = WHISPER::StringData(response);
LOG_S(INFO)<<"message from cms: "<< message.data_;
j["Tracks"] = nlohmann::json::parse(message.data_);
nlohmann::json Jsontracks;
auto tracks = update->getTracks();
LOG_S(INFO)<<"Tracklist Update Size: " <<tracks.size();
for(auto item : tracks)
{
Jsontracks.push_back(item.getsTrackListItemAsJSON());
}
j["Tracks"] = Jsontracks;
// auto update = SimCore::TracklistUpdate::unpack(WHISPER::Message(response));
// if(update == nullptr)
// {
// LOG_S(INFO)<<"no update received";
// return;
// }
}catch (const std::exception e) {
// nlohmann::json Jsontracks;
// auto tracks = update->getTracks();
// LOG_S(INFO)<<"Tracklist Update Size: " <<tracks.size();
// for(auto item : tracks)
// {
// Jsontracks.push_back(item.getsTrackListItemAsJSON());
// }
// j["Tracks"] = Jsontracks;
}catch (const std::exception &e) {
LOG_S(ERROR)<< e.what();
}
@@ -599,9 +605,9 @@ namespace SimControl {
{
// std::string uuid = xg::newGuid().str();
if (online_ != false) {
startWebApp();
startShip("hamburg");
startNewShip("Test", "55.16131", "7.86004", "0", "0", "0");
startWebApp();
}