Example #1
0
  private static void recuperacionFallas() {
    File file = new File(serverName + ".swp");
    if (file.exists()) {
      try {
        System.out.println("Un fichero de salvaguarda es presente:");
        System.out.println("Quiere recuperar el antiguo juego(y/n)?");
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
          String s = in.readLine();
          if (s.equals("y")) {
            recuperationServer();
            InputStream ips = new FileInputStream(serverName + ".swp");
            InputStreamReader ipsr = new InputStreamReader(ips);
            BufferedReader br = new BufferedReader(ipsr);
            String info = br.readLine();
            reconstruction(info);
            game.setRecoveringServer(false);
            break;
          } else if (s.equals("n")) {
            serverInit();
            break;
          }
        }

      } catch (FileNotFoundException e) {
        System.out.println("Failed to wait");
      } catch (IOException e) {
        System.out.println("Failed to wait");
      }

    } else serverInit();
    saveStateServer();
  }
Example #2
0
 public static void recuperationServer() {
   String serverAddress = "rmi://" + serverInfo.getIpAddr() + ":1099/I_InfoGame";
   try {
     Naming.unbind(serverAddress);
     game = new InfoGame();
     server = new Server();
     game.setServer(server);
     game.setServerAddress(serverInfo.getIpAddr());
     game.setNextAddress(serverInfo.getNext().getIpAddr());
     game.setNbPlayerExpected(numPlayer);
     game.setRecoveringServer(true);
     Naming.rebind(serverAddress, game);
     socketPortClient = serverInfo.getPortClient();
   } catch (NotBoundException e) {
     System.out.println("El servicio no esta publicado");
   } catch (RemoteException e) {
     System.out.println("Hubo una excepcion creando la instancia del objeto distribuido");
   } catch (MalformedURLException e) {
     System.out.println("URL mal formada al tratar de publicar el objeto");
   }
 }