From 9d4292732c1db2de2e9545ac9d91b431aa98ebad Mon Sep 17 00:00:00 2001 From: ulrich Date: Sun, 30 Mar 2025 17:23:05 +0000 Subject: [PATCH] Maschine Ausschalten nach einer Minute, sodass der Server zuvor herunter fahren kann. --- src/de/uhilger/calypso/http/ApiHandler.java | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/de/uhilger/calypso/http/ApiHandler.java b/src/de/uhilger/calypso/http/ApiHandler.java index bcdf2a3..ba978fe 100644 --- a/src/de/uhilger/calypso/http/ApiHandler.java +++ b/src/de/uhilger/calypso/http/ApiHandler.java @@ -20,6 +20,7 @@ import com.sun.net.httpserver.HttpContext; import com.sun.net.httpserver.HttpExchange; +import de.uhilger.calypso.actor.DownServerActor; import de.uhilger.calypso.actor.PlayActor; import de.uhilger.calypso.actor.ShellActor; import de.uhilger.calypso.actor.StopServerActor; @@ -53,6 +54,7 @@ public static final String STOP = "stop"; public static final String SERVER = "server"; public static final String PING = "ping"; + public static final String DOWN = "down"; public static final String PLAYER = "player-proc"; @@ -109,7 +111,8 @@ break; case SERVER: - if(elems[SERVERCMD].equals(STOP)) { + switch (elems[SERVERCMD]) { + case STOP: try { antwort = "Calypso: Der Server wird angehalten und die App beendet."; sendResponse(exchange, antwort); @@ -118,10 +121,23 @@ Logger.getLogger(ApiHandler.class.getName()).log(Level.SEVERE, null, ex); antwort = "Fehler: " + ex.getLocalizedMessage(); } - } else { + break; + case DOWN: + try { + antwort = "Calypso: Der Server wird angehalten, die App beendet und die Maschine ausgeschaltet."; + sendResponse(exchange, antwort); + new DownServerActor().run(exchange.getHttpContext()); + } catch (IOException ex) { + Logger.getLogger(ApiHandler.class.getName()).log(Level.SEVERE, null, ex); + antwort = "Fehler: " + ex.getLocalizedMessage(); + } + break; + default: antwort = elems[SERVERCMD] + " ist ein unbekanntes Serverkommando"; - } + break; + } break; + case PING: antwort = elems[PLAYERCMD]; -- Gitblit v1.9.3