Added a choice in ClientP2P to choose TCP transport protocol
This commit is contained in:
parent
d01bbd85f2
commit
c17a7e6cd5
@ -1,7 +1,8 @@
|
||||
package clientP2P;
|
||||
import clientP2P.ClientManagementUDP;
|
||||
import clientP2P.ClientManagementTCP;
|
||||
import tools.Directories;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class ClientP2P {
|
||||
private String host;
|
||||
@ -17,7 +18,22 @@ public class ClientP2P {
|
||||
|
||||
public static void main(String [] args) {
|
||||
ClientP2P c = new ClientP2P();
|
||||
ClientManagementUDP cm = new ClientManagementUDP(c.directories.getDataHomeDirectory(), c.host, c.port);
|
||||
System.out.println("Which transport protocol do you want to use? [TCP/udp]");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String transportchoosen = sc.nextLine();
|
||||
switch(transportchoosen){
|
||||
case "UDP":
|
||||
case "udp":
|
||||
case "2" :
|
||||
ClientManagementUDP cm = new ClientManagementUDP(c.directories.getDataHomeDirectory(), c.host, c.port);
|
||||
break;
|
||||
case "TCP":
|
||||
case "tcp":
|
||||
case "1":
|
||||
default:
|
||||
ClientManagementTCP cm = new ClientManagementTCP(c.directories.getDataHomeDirectory(), c.host, c.port);
|
||||
break;
|
||||
}
|
||||
Thread t = new Thread(cm);
|
||||
t.setName("client P2P-JAVA-PROJECT");
|
||||
t.start();
|
||||
|
Loading…
Reference in New Issue
Block a user