public void disconnect(String name, I_InfoPlayer player) { try { Naming.unbind("rmi://" + serverInfo.getIpAddr() + ":1099/I_InfoGame"); Naming.unbind("rmi://" + serverInfo.getIpAddr() + ":1099/" + name); } catch (Exception e) { System.out.println("Failed unbind"); System.exit(128); } System.out.println("Disconnected"); ServerTimer timer = new ServerTimer(5); Thread thread = new Thread(timer); thread.start(); while (!timer.finished()) ; timer.shutDown(); timer = null; System.gc(); try { Naming.rebind("rmi://" + serverAddress + ":1099/I_InfoGame", game); Naming.rebind("rmi://" + serverAddress + ":1099/" + name, player); } catch (Exception e) { System.out.println("Failed rebind"); System.exit(128); } System.out.println("Reconnected"); }
private static void serverRunning() { System.out.println("Server Running"); ServerTimer timer = new ServerTimer(60); Thread thread = new Thread(timer); thread.start(); // System.out.println("Waiting for timer"); while (!timer.finished()) ; timer.shutDown(); // System.out.println("Migration !"); timer = null; System.gc(); try { game.setMoving(true); serverCall(); } catch (RemoteException e) { System.out.println("Failed to modify game"); System.exit(1); } catch (Exception ex) { System.out.println("Failed to call"); } }