diff --git a/src/confighttp.cpp b/src/confighttp.cpp index d6b60c0f2ad..6559e76cba3 100644 --- a/src/confighttp.cpp +++ b/src/confighttp.cpp @@ -298,6 +298,13 @@ void saveApp(resp_https_t response, req_https_t request) { pt::read_json(ss, inputTree); pt::read_json(config::stream.file_apps, fileTree); + // Moonlight checks the id of an item to determine if an item was changed + // Add a property named "id" to the inputTree with a value of the current timestamp + // Time is in seconds because some Moonlight clients cannot accept more than a 32-bit integer + // Milliseconds would be a better option + time_t id = time(nullptr); + inputTree.put("id", id); + if(inputTree.get_child("prep-cmd").empty()) { inputTree.erase("prep-cmd"); } diff --git a/src/nvhttp.cpp b/src/nvhttp.cpp index 9ffda1b4e70..30e2a383dc0 100644 --- a/src/nvhttp.cpp +++ b/src/nvhttp.cpp @@ -687,9 +687,18 @@ void applist(resp_https_t response, req_https_t request) { for(auto &proc : proc::proc.get_apps()) { pt::ptree app; + // Check if the "id" field is empty + if(!proc.id.empty()) { + // Use the "id" field if it is not empty + app.put("ID", proc.id); + } + else { + // Otherwise, use the "x" counter to set the ID + app.put("ID", ++x); + } + app.put("IsHdrSupported"s, config::video.hevc_mode == 3 ? 1 : 0); app.put("AppTitle"s, proc.name); - app.put("ID"s, ++x); apps.push_back(std::make_pair("App", std::move(app))); } diff --git a/src/process.h b/src/process.h index eab324a7887..ed951ff44b7 100644 --- a/src/process.h +++ b/src/process.h @@ -54,6 +54,7 @@ struct ctx_t { std::string working_dir; std::string output; std::string image_path; + std::string id; }; class proc_t {