Ejemplo n.º 1
0
  public static void main(String[] args) {
    System.out.println("hello client");
    init();
    System.out.println("Connecting to server...");
    connect();
    if (serverPortal == null) {
      System.out.println("did not find active server");
      System.exit(1);
    }

    boolean connected = false;
    do {
      try {
        userSession = new Login(serverPortal);
        connected = userSession.login();
      } catch (RemoteException ex) {
        reconnect(ex);
      }
    } while (!connected);

    String localPath = userSession.getSyncPath();
    String tempPath = userSession.getMetaPath();
    String userName = userSession.getUserName();
    String device = userSession.getDeviceID();
    String dataPath = tempPath + "filelist.obj";

    try {
      boolean recursive = false;
      watchService = new WatchDir(localPath, recursive, userName, device, dataPath);

    } catch (IOException ex) {
      System.out.println("HI IO");
      System.out.println(ex.getMessage());
    }
    new Thread(watchService).start();
    sync = new Sync(userName, device, serverPortal, localPath, tempPath, dataPath);
    sync.setClientFileList(watchService.loadFileList());
    startSync();
  }