Remove debugs print
This commit is contained in:
parent
ecc92f79d1
commit
789c0c0257
@ -48,7 +48,7 @@ public class ClientManagementUDP implements Runnable {
|
|||||||
msg = sendMsg(sendDownloadRequest(f));
|
msg = sendMsg(sendDownloadRequest(f));
|
||||||
download(msg, f);
|
download(msg, f);
|
||||||
} catch (TransmissionError e) {
|
} catch (TransmissionError e) {
|
||||||
System.out.println("TransmissionError");
|
System.out.println("Transmission error");
|
||||||
} catch (ProtocolError e) {
|
} catch (ProtocolError e) {
|
||||||
System.out.println("Protocol error");
|
System.out.println("Protocol error");
|
||||||
} catch (NotFound e) {
|
} catch (NotFound e) {
|
||||||
@ -143,11 +143,8 @@ public class ClientManagementUDP implements Runnable {
|
|||||||
DatagramPacket reception = new DatagramPacket(buffer, buffer.length);
|
DatagramPacket reception = new DatagramPacket(buffer, buffer.length);
|
||||||
DatagramPacket emission = new DatagramPacket(buffer, buffer.length, dst, UDPPort);
|
DatagramPacket emission = new DatagramPacket(buffer, buffer.length, dst, UDPPort);
|
||||||
socket.send(emission);
|
socket.send(emission);
|
||||||
System.out.print(msg);
|
|
||||||
socket.receive(reception);
|
socket.receive(reception);
|
||||||
String tmp = new String(reception.getData(), 0, reception.getLength());
|
return new String(reception.getData(), 0, reception.getLength());
|
||||||
System.out.print(tmp);
|
|
||||||
return tmp;
|
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
throw new TransmissionError();
|
throw new TransmissionError();
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ public class ClientP2P {
|
|||||||
// create directory if not already exists
|
// create directory if not already exists
|
||||||
new File(d).mkdirs();
|
new File(d).mkdirs();
|
||||||
directory = d;
|
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) {
|
public static void main(String [] args) {
|
||||||
|
@ -67,19 +67,18 @@ public class ServerManagementUDP implements Runnable {
|
|||||||
* @return data to be send as response
|
* @return data to be send as response
|
||||||
*/
|
*/
|
||||||
String processRequest(String request) {
|
String processRequest(String request) {
|
||||||
System.out.print(request);
|
|
||||||
String res = protocolID + "\n";
|
String res = protocolID + "\n";
|
||||||
String formattedRequest[] = request.split("\n");
|
String formattedRequest[] = request.split("\n");
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
checkProtocolID(formattedRequest[0]);
|
checkProtocolID(formattedRequest[0]);
|
||||||
System.out.print("juste avant le switch");
|
|
||||||
switch (formattedRequest[1]) {
|
switch (formattedRequest[1]) {
|
||||||
case "LIST":
|
case "LIST":
|
||||||
System.out.print("liste detectee");
|
System.out.println("List request");
|
||||||
res += sendFileList();
|
res += sendFileList();
|
||||||
break;
|
break;
|
||||||
case "DOWNLOAD":
|
case "DOWNLOAD":
|
||||||
|
System.out.println("Download request: " + formattedRequest[2]);
|
||||||
res += upload(formattedRequest[2]);
|
res += upload(formattedRequest[2]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -102,7 +101,6 @@ public class ServerManagementUDP implements Runnable {
|
|||||||
/** Initialize local list of all files allowed to be shared.
|
/** Initialize local list of all files allowed to be shared.
|
||||||
*/
|
*/
|
||||||
private void initFileList() {
|
private void initFileList() {
|
||||||
System.out.println(baseDirectory);
|
|
||||||
File folder = new File(baseDirectory);
|
File folder = new File(baseDirectory);
|
||||||
File[] files = folder.listFiles();
|
File[] files = folder.listFiles();
|
||||||
/* Add non-recursively files's names to fileList */
|
/* Add non-recursively files's names to fileList */
|
||||||
@ -119,7 +117,6 @@ public class ServerManagementUDP implements Runnable {
|
|||||||
* @throws ProtocolError
|
* @throws ProtocolError
|
||||||
*/
|
*/
|
||||||
private void checkProtocolID(String msgProtocolID) throws ProtocolError {
|
private void checkProtocolID(String msgProtocolID) throws ProtocolError {
|
||||||
System.out.print(msgProtocolID + "\n" + protocolID);
|
|
||||||
if (!protocolID.equals(msgProtocolID)) {
|
if (!protocolID.equals(msgProtocolID)) {
|
||||||
throw new ProtocolError();
|
throw new ProtocolError();
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ public class ServerP2P {
|
|||||||
// create directory if not already exists
|
// create directory if not already exists
|
||||||
new File(d).mkdirs();
|
new File(d).mkdirs();
|
||||||
directory = d;
|
directory = d;
|
||||||
|
System.out.println("Server will listen on port " + port + " and serve files from " + directory);
|
||||||
}
|
}
|
||||||
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