package jguard.client;

import cucky.jGuard.lib.LogFile;
import java.util.logging.Level;
import java.util.logging.Logger;
import jguard.client.network.NetworkClient;

public class AutoConnect extends Thread {
    
    private boolean exit = false;

    @Override
    public void run() {
        super.run();

        LogFile.printInfo("Automaticke pripojovani");
        while (!exit) {
            Client.client = new NetworkClient(Client.config.getProperty("server"), Integer.valueOf(Client.config.getProperty("port")));
            Client.client.start();
            if (Client.client.isConnected()) {
                exit = true;
            } else {
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException ex) {
                    Logger.getLogger(AutoConnect.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
        
        LogFile.printInfo("Automaticke pripojovani ukonceno");

    }

}
