From 789c0c0257a1440172e7141a29786e009f5106a5 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 14 Jan 2020 12:33:21 +0100 Subject: [PATCH] Remove debugs print --- src/clientP2P/ClientManagementUDP.java | 7 ++----- src/clientP2P/ClientP2P.java | 1 + src/serverP2P/ServerManagementUDP.java | 7 ++----- src/serverP2P/ServerP2P.java | 1 + 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/clientP2P/ClientManagementUDP.java b/src/clientP2P/ClientManagementUDP.java index 3cd83c3..19756fb 100644 --- a/src/clientP2P/ClientManagementUDP.java +++ b/src/clientP2P/ClientManagementUDP.java @@ -48,7 +48,7 @@ public class ClientManagementUDP implements Runnable { msg = sendMsg(sendDownloadRequest(f)); download(msg, f); } catch (TransmissionError e) { - System.out.println("TransmissionError"); + System.out.println("Transmission error"); } catch (ProtocolError e) { System.out.println("Protocol error"); } catch (NotFound e) { @@ -143,11 +143,8 @@ public class ClientManagementUDP implements Runnable { DatagramPacket reception = new DatagramPacket(buffer, buffer.length); DatagramPacket emission = new DatagramPacket(buffer, buffer.length, dst, UDPPort); socket.send(emission); - System.out.print(msg); socket.receive(reception); - String tmp = new String(reception.getData(), 0, reception.getLength()); - System.out.print(tmp); - return tmp; + return new String(reception.getData(), 0, reception.getLength()); } catch (Exception e){ throw new TransmissionError(); } diff --git a/src/clientP2P/ClientP2P.java b/src/clientP2P/ClientP2P.java index 862b2d6..7c9e7de 100644 --- a/src/clientP2P/ClientP2P.java +++ b/src/clientP2P/ClientP2P.java @@ -30,6 +30,7 @@ public class ClientP2P { // create directory if not already exists new File(d).mkdirs(); directory = d; + System.out.println("Client will try to contact server at " + host + " on port " + port + ". It will save files in " + directory); } public static void main(String [] args) { diff --git a/src/serverP2P/ServerManagementUDP.java b/src/serverP2P/ServerManagementUDP.java index 6397248..c9506dd 100644 --- a/src/serverP2P/ServerManagementUDP.java +++ b/src/serverP2P/ServerManagementUDP.java @@ -67,19 +67,18 @@ public class ServerManagementUDP implements Runnable { * @return data to be send as response */ String processRequest(String request) { - System.out.print(request); String res = protocolID + "\n"; String formattedRequest[] = request.split("\n"); try { try { checkProtocolID(formattedRequest[0]); - System.out.print("juste avant le switch"); switch (formattedRequest[1]) { case "LIST": - System.out.print("liste detectee"); + System.out.println("List request"); res += sendFileList(); break; case "DOWNLOAD": + System.out.println("Download request: " + formattedRequest[2]); res += upload(formattedRequest[2]); break; default: @@ -102,7 +101,6 @@ public class ServerManagementUDP implements Runnable { /** Initialize local list of all files allowed to be shared. */ private void initFileList() { - System.out.println(baseDirectory); File folder = new File(baseDirectory); File[] files = folder.listFiles(); /* Add non-recursively files's names to fileList */ @@ -119,7 +117,6 @@ public class ServerManagementUDP implements Runnable { * @throws ProtocolError */ private void checkProtocolID(String msgProtocolID) throws ProtocolError { - System.out.print(msgProtocolID + "\n" + protocolID); if (!protocolID.equals(msgProtocolID)) { throw new ProtocolError(); } diff --git a/src/serverP2P/ServerP2P.java b/src/serverP2P/ServerP2P.java index 5517180..399ad31 100644 --- a/src/serverP2P/ServerP2P.java +++ b/src/serverP2P/ServerP2P.java @@ -28,6 +28,7 @@ public class ServerP2P { // create directory if not already exists new File(d).mkdirs(); directory = d; + System.out.println("Server will listen on port " + port + " and serve files from " + directory); } public static void main(String [] args) { ServerP2P s = new ServerP2P();