diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java index 97295da2..204e1138 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java @@ -296,4 +296,21 @@ public void broadcast(ServerMessage message) { public void disconnectClient(int id) { this.myServer.getConnection(id).close(""); } + + /** + * This method will be used to shut down the server. + * It will iterate threw all connections of myServer attribute and check if they are equal to null. If not they will + * be closed. After that the myServer attribute will be closed and this program will be exited with the exit code 0. + */ + @Override + public void shutdown() { + for (HostedConnection client : this.myServer.getConnections()) { + if (client != null) { + client.close("Host closed the server."); + } + } + + this.myServer.close(); + this.exit(0); + } }