From c17a7e6cd5955d3592ab0fc0d557359d4c2bd652 Mon Sep 17 00:00:00 2001 From: flavien Date: Mon, 3 Feb 2020 14:48:56 +0100 Subject: [PATCH] Added a choice in ClientP2P to choose TCP transport protocol --- src/clientP2P/ClientP2P.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/clientP2P/ClientP2P.java b/src/clientP2P/ClientP2P.java index 8ee0186..5deb0ea 100644 --- a/src/clientP2P/ClientP2P.java +++ b/src/clientP2P/ClientP2P.java @@ -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();