public void run(Server server) { // To restart the server after it has been stopped by us. try { if (!server.getOnline() && !server.isDownloading() && restartNextRun) { server.startServer(); restartNextRun = false; } } catch (Exception e) { e.printStackTrace(); } if (!server.getOnline()) return; // if (lastRestart != null && System.currentTimeMillis() - lastRestart.getTime() < // globalTimeout * 3600000) return; // Restart Schedule if (enableRestartSchedule) { Calendar calendar = Calendar.getInstance(); switch (runningSchedule) { case NONE: calendar.add(Calendar.MINUTE, 15); if (calendar.get(Calendar.HOUR_OF_DAY) == restartScheduleHours && calendar.get(Calendar.MINUTE) == restartScheduleMinutes) { runningSchedule = ScheduleStep.M15; } break; default: calendar.add(Calendar.MINUTE, runningSchedule.timeLeft); if (calendar.get(Calendar.HOUR_OF_DAY) == restartScheduleHours && calendar.get(Calendar.MINUTE) == restartScheduleMinutes) { server.sendChat( restartScheduleMessage.replace( "%time", Integer.toString(runningSchedule.timeLeft))); runningSchedule = runningSchedule.nextStep; } break; case NOW: runningSchedule = ScheduleStep.NONE; initReboot(server, "Restarting on schedule."); } } // Empty check // if (server.getPlayerList().size() == 0 && whenEmptyTimeout != -1) // { // if (emptyDate == null) emptyDate = new Date(); // else if (System.currentTimeMillis() - emptyDate.getTime() > whenEmptyTimeout * // 60000) // { // initReboot(server, "Server restart because empty."); // } // } // else emptyDate = null; }
protected void startServer() throws IOException { String file = getClass().getResource("/").getPath(); System.setProperty("moquette.path", file); m_server = new Server(); Properties sslProps = new Properties(); sslProps.put(io.moquette.commons.Constants.SSL_PORT_PROPERTY_NAME, "8883"); sslProps.put(Constants.JKS_PATH_PROPERTY_NAME, "serverkeystore.jks"); sslProps.put(Constants.KEY_STORE_PASSWORD_PROPERTY_NAME, "passw0rdsrv"); sslProps.put(Constants.KEY_MANAGER_PASSWORD_PROPERTY_NAME, "passw0rdsrv"); sslProps.put(Constants.PERSISTENT_STORE_PROPERTY_NAME, IntegrationUtils.localMapDBPath()); m_server.startServer(sslProps); }
public Server() { generator = new JSONGenerator(); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setSize(500, 500); setLocationRelativeTo(null); connected = false; setResizable(false); setTitle("Server"); initialiseGUI(); pack(); startServer(); setVisible(true); }
public static void main(String[] args) { Clock clock = new Clock() { @Override public Date now() { Calendar calendar = Calendar.getInstance(); return calendar.getTime(); } }; ServerView serverView = new ServerView(); ServerMessages serverMessages = new SerMessage(); Server server = new Server(serverView, serverMessages, clock, 4444); serverView.setServer(server); server.startServer(); }
public static void main(String args[]) { Game.game = new Game(); Game.game.start(); startServer(); }