public static void serverMenu() { boolean serverRunning = true; while (serverRunning) { Tui.miscOut("\n***Welcome to the Snake server***\n"); Tui.miscOut("What do you want to do?"); Tui.miscOut("1) Login as admin"); Tui.miscOut("2) Stop server"); switch (input.nextInt()) { case 1: login(); break; case 2: serverRunning = false; break; default: Tui.miscOut("Unassigned key."); } } }
public static void main(String[] args) throws IOException { Config.init(); HttpServer server = HttpServerFactory.create("http://localhost:" + Config.getServerPort() + "/"); server.start(); System.out.println("Server running"); System.out.println("Visit: http://localhost:" + Config.getServerPort() + "/api"); Tui.serverMenu(); System.out.println("Hit return to confirm to stop..."); System.in.read(); System.out.println("Stopping server"); server.stop(0); System.out.println("Server stopped"); }