2020-01-14 11:10:11 +01:00
|
|
|
package clientP2P;
|
|
|
|
import clientP2P.ClientManagementUDP;
|
2020-01-16 12:35:06 +01:00
|
|
|
import tools.Directories;
|
2020-01-21 11:21:34 +01:00
|
|
|
import java.util.Scanner;
|
2019-12-12 11:57:02 +01:00
|
|
|
|
2020-01-14 11:10:11 +01:00
|
|
|
public class ClientP2P {
|
2020-01-12 23:29:49 +01:00
|
|
|
private String host;
|
|
|
|
private int port;
|
2020-01-16 12:35:06 +01:00
|
|
|
private String dataHomeDirectory;
|
2020-01-14 11:10:11 +01:00
|
|
|
public ClientP2P() {
|
2020-01-21 11:21:34 +01:00
|
|
|
Directories d = new Directories("P2P_JAVA_PROJECT_CLIENT");
|
|
|
|
String os = System.getProperty("os.name");
|
|
|
|
|
2020-01-12 23:29:49 +01:00
|
|
|
host = "localhost";
|
|
|
|
port = 40000;
|
2020-01-21 11:21:34 +01:00
|
|
|
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();
|
2020-01-21 11:23:55 +01:00
|
|
|
if (resp.equals("y") || resp.equals("Y")) {
|
|
|
|
System.out.println("Openning");
|
2020-01-21 11:21:34 +01:00
|
|
|
d.openDataHomeDirectory();
|
|
|
|
}
|
|
|
|
}
|
2020-01-12 23:29:49 +01:00
|
|
|
}
|
2020-01-14 11:10:11 +01:00
|
|
|
|
2019-12-12 11:57:02 +01:00
|
|
|
public static void main(String [] args) {
|
2020-01-14 11:10:11 +01:00
|
|
|
ClientP2P c = new ClientP2P();
|
2020-01-16 12:35:06 +01:00
|
|
|
ClientManagementUDP cm = new ClientManagementUDP(c.dataHomeDirectory, c.host, c.port);
|
2020-01-12 23:29:49 +01:00
|
|
|
Thread t = new Thread(cm);
|
|
|
|
t.setName("client P2P-JAVA-PROJECT");
|
|
|
|
t.start();
|
2019-12-12 11:57:02 +01:00
|
|
|
}
|
|
|
|
}
|