package clientP2P;
import clientP2P.ClientManagementUDP;
import tools.Directories;
import java.util.Scanner;

public class ClientP2P {
	private String host;
	private int port;
	private String dataHomeDirectory;
	public ClientP2P() {
		Directories d = new Directories("P2P_JAVA_PROJECT_CLIENT");
		String os = System.getProperty("os.name");

		host = "localhost";
		port = 40000;
		dataHomeDirectory = d.getDataHomeDirectory();
		System.out.println("Client will try to contact server at " + host + " on port " + port + ". It will save files in " + dataHomeDirectory);
		if (os.equals("Linux")||os.equals("Mac")||os.equals("Mac OS X")) {
			System.out.println("Do you want to open this directory? (y/N)");
			Scanner scanner = new Scanner(System.in);
			String resp = scanner.nextLine();
			if (resp == "y" || resp == "Y") {
				d.openDataHomeDirectory();
			}
		}
	}

	public static void main(String [] args) {
		ClientP2P c = new ClientP2P();
		ClientManagementUDP cm = new ClientManagementUDP(c.dataHomeDirectory, c.host, c.port);
		Thread t = new Thread(cm);
		t.setName("client P2P-JAVA-PROJECT");
		t.start();
	}
}