2019-12-12 11:57:02 +01:00
|
|
|
package client;
|
|
|
|
|
|
|
|
public class Client {
|
2020-01-12 23:29:49 +01:00
|
|
|
private String host;
|
|
|
|
private int port;
|
|
|
|
private String directory;
|
2019-12-12 11:57:02 +01:00
|
|
|
public Client() {
|
2020-01-12 23:29:49 +01:00
|
|
|
host = "localhost";
|
|
|
|
port = 40000;
|
|
|
|
String d;
|
|
|
|
/* Follow XDG Base Directory Specification
|
|
|
|
* https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
|
|
*/
|
|
|
|
if (System.getProperty("os.name").equals("Linux")) {
|
|
|
|
d = System.getenv().get("XDG_DATA_HOME");
|
|
|
|
if (d == null || f.equals("")) {
|
|
|
|
d = System.getenv().get("HOME");
|
|
|
|
if (d != null && (!f.equals(""))) {
|
|
|
|
d += "/.local/share";
|
|
|
|
} else {
|
|
|
|
d += "."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
d = ".";
|
|
|
|
}
|
|
|
|
d += "P2P_JAVA_PROJECT_CLIENT/";
|
|
|
|
// create directory if not already exists
|
|
|
|
new File(d).mkdirs();
|
|
|
|
}
|
2019-12-12 11:57:02 +01:00
|
|
|
}
|
|
|
|
public static void main(String [] args) {
|
|
|
|
Client c = new Client("client");
|
2020-01-12 23:29:49 +01:00
|
|
|
ClientManagementUDP cm = new ClientManagementUDP(c.directory, c.host, c.port);
|
|
|
|
Thread t = new Thread(cm);
|
|
|
|
t.setName("client P2P-JAVA-PROJECT");
|
|
|
|
t.start();
|
2019-12-12 11:57:02 +01:00
|
|
|
}
|
|
|
|
}
|