Add openning functionnality to server
This commit is contained in:
parent
a4bb32bf44
commit
3a27d84690
@ -1,14 +1,27 @@
|
|||||||
package serverP2P;
|
package serverP2P;
|
||||||
import serverP2P.ServerManagementUDP;
|
import serverP2P.ServerManagementUDP;
|
||||||
import tools.Directories;
|
import tools.Directories;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class ServerP2P {
|
public class ServerP2P {
|
||||||
private int port;
|
private int port;
|
||||||
private String dataHomeDirectory;
|
private String dataHomeDirectory;
|
||||||
public ServerP2P() {
|
public ServerP2P() {
|
||||||
|
Directories d = new Directories("P2P_JAVA_PROJECT_SERVER");
|
||||||
|
String os = System.getProperty("os.name");
|
||||||
|
|
||||||
port = 40000;
|
port = 40000;
|
||||||
dataHomeDirectory = new Directories("P2P_JAVA_PROJECT_SERVER").getDataHomeDirectory();
|
dataHomeDirectory = d.getDataHomeDirectory();
|
||||||
System.out.println("Server will listen on port " + port + " and serve files from " + dataHomeDirectory);
|
System.out.println("Server will listen on port " + port + " and serve files from " + 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.equals("y") || resp.equals("Y")) {
|
||||||
|
System.out.println("Openning");
|
||||||
|
d.openDataHomeDirectory();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static void main(String [] args) {
|
public static void main(String [] args) {
|
||||||
ServerP2P s = new ServerP2P();
|
ServerP2P s = new ServerP2P();
|
||||||
|
Loading…
Reference in New Issue
Block a user