Skip to content

Commit 65a54ad

Browse files
committed
refactoring
1 parent 83378ca commit 65a54ad

File tree

6 files changed

+469
-323
lines changed

6 files changed

+469
-323
lines changed

src/confighttp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ namespace confighttp {
584584
});
585585

586586
file_handler::write_file(config::stream.file_apps.c_str(), file_tree.dump(4));
587-
proc::refresh(config::stream.file_apps);
587+
proc::proc.refresh(config::stream.file_apps);
588588

589589
output_tree["status"] = true;
590590
send_response(response, output_tree);
@@ -656,7 +656,7 @@ namespace confighttp {
656656
file_tree["apps"] = new_apps;
657657

658658
file_handler::write_file(config::stream.file_apps.c_str(), file_tree.dump(4));
659-
proc::refresh(config::stream.file_apps);
659+
proc::proc.refresh(config::stream.file_apps);
660660

661661
output_tree["status"] = true;
662662
output_tree["result"] = "application " + std::to_string(index) + " deleted";

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ int main(int argc, char *argv[]) {
276276
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
277277
#endif
278278

279-
proc::refresh(config::stream.file_apps);
279+
proc::proc.refresh(config::stream.file_apps);
280280

281281
// If any of the following fail, we log an error and continue event though sunshine will not function correctly.
282282
// This allows access to the UI to fix configuration problems or view the logs.

src/nvhttp.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -753,10 +753,10 @@ namespace nvhttp {
753753
}
754754
tree.put("root.ServerCodecModeSupport", codec_mode_flags);
755755

756-
auto current_appid = proc::proc.running();
756+
auto current_appid = proc::proc.get_running_app_id();
757757
tree.put("root.PairStatus", pair_status);
758-
tree.put("root.currentgame", current_appid);
759-
tree.put("root.state", current_appid > 0 ? "SUNSHINE_SERVER_BUSY" : "SUNSHINE_SERVER_FREE");
758+
tree.put("root.currentgame", current_appid.value_or(0));
759+
tree.put("root.state", current_appid ? "SUNSHINE_SERVER_BUSY" : "SUNSHINE_SERVER_FREE");
760760

761761
std::ostringstream data;
762762

@@ -837,10 +837,7 @@ namespace nvhttp {
837837
return;
838838
}
839839

840-
auto appid = util::from_view(get_arg(args, "appid"));
841-
842-
auto current_appid = proc::proc.running();
843-
if (current_appid > 0) {
840+
if (proc::proc.get_running_app_id()) {
844841
tree.put("root.resume", 0);
845842
tree.put("root.<xmlattr>.status_code", 400);
846843
tree.put("root.<xmlattr>.status_message", "An app is already running on this host");
@@ -884,6 +881,7 @@ namespace nvhttp {
884881
return;
885882
}
886883

884+
auto appid = util::from_view(get_arg(args, "appid"));
887885
if (appid > 0) {
888886
auto err = proc::proc.execute(appid, launch_session);
889887
if (err) {
@@ -917,8 +915,7 @@ namespace nvhttp {
917915
response->close_connection_after_response = true;
918916
});
919917

920-
auto current_appid = proc::proc.running();
921-
if (current_appid == 0) {
918+
if (!proc::proc.get_running_app_id()) {
922919
tree.put("root.resume", 0);
923920
tree.put("root.<xmlattr>.status_code", 503);
924921
tree.put("root.<xmlattr>.status_message", "No running app to resume");
@@ -1000,12 +997,9 @@ namespace nvhttp {
1000997
tree.put("root.<xmlattr>.status_code", 200);
1001998

1002999
rtsp_stream::terminate_sessions();
1000+
proc::proc.terminate();
10031001

1004-
if (proc::proc.running() > 0) {
1005-
proc::proc.terminate();
1006-
}
1007-
1008-
// The config needs to be reverted regardless of whether "proc::proc.terminate()" was called or not.
1002+
// The config needs to be reverted regardless of whether "proc::proc.terminate()" actually terminated app or not.
10091003
display_device::revert_configuration();
10101004
}
10111005

0 commit comments

Comments
 (0)