mirror of
https://github.com/binlaab/nanofiles.git
synced 2026-07-01 20:06:28 +02:00
arreglado ping y empezado peerdl y dirdl
This commit is contained in:
@@ -259,6 +259,7 @@ public class DirectoryConnector {
|
||||
byte[] resp = sendAndReceiveDatagrams(pingBytes);
|
||||
String respStr = new String(resp, 0, resp.length);
|
||||
DirMessage respPing = DirMessage.fromString(respStr);
|
||||
System.out.println("pingDir - " + respPing.getOperation());
|
||||
success = (respPing.getOperation().equals(DirMessageOps.OPERATION_PING_OK));
|
||||
|
||||
|
||||
@@ -355,9 +356,14 @@ public class DirectoryConnector {
|
||||
String filename = null;
|
||||
long filesize = -1;
|
||||
String filehash = null;
|
||||
|
||||
|
||||
|
||||
|
||||
FileInfo[] list = this.getFileList();
|
||||
FileInfo[] foundFile = FileInfo.lookupHashSubstring(list, hashSubstring);
|
||||
|
||||
// TODO: crear nuevo mensaje dirdl y requestdirdl
|
||||
// similar a un mensaje peerdl
|
||||
// pasarle hashSubstring a DirMessage y dejar que vaya desde ahí
|
||||
// implementar toda la lógica en DirMessage
|
||||
return new DownloadedFile(filename, filesize, fileData, filehash);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,10 @@ public class DirMessage {
|
||||
public String getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(String op) {
|
||||
this.operation = op;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: (Boletín MensajesASCII) Crear métodos getter y setter para obtener los
|
||||
@@ -213,7 +217,7 @@ public class DirMessage {
|
||||
|
||||
for (int i = 0; i < archivos.length; i++) {
|
||||
String[] atributos = archivos[i].split(":");
|
||||
FileInfo archivo = new FileInfo(atributos[2], atributos[0], Long.parseLong(atributos[1]), null); // de momento no meto el path
|
||||
FileInfo archivo = new FileInfo(atributos[2], atributos[0], Long.parseLong(atributos[1]), atributos[3]); // de momento no meto el path
|
||||
listaArchivos[i] = archivo;
|
||||
}
|
||||
|
||||
@@ -280,7 +284,7 @@ public class DirMessage {
|
||||
sb.append(FIELDNAME_FILELIST + DELIMITER);
|
||||
for (int i = 0; i < fileList.length; i++) {
|
||||
FileInfo f = fileList[i];
|
||||
sb.append(f.fileName + ':' + f.fileSize + ':' + f.fileHash);
|
||||
sb.append(f.fileName + ':' + f.fileSize + ':' + f.fileHash + ':' + f.filePath);
|
||||
if (i < fileList.length - 1) {
|
||||
sb.append(','); // para evitar una coma al final
|
||||
}
|
||||
|
||||
@@ -226,13 +226,13 @@ public class NFDirectoryServer {
|
||||
* done: (Boletín MensajesASCII) Comprobamos si el protocolId del mensaje del
|
||||
* cliente coincide con el nuestro.
|
||||
*/
|
||||
msgToSend = new DirMessage(operation);
|
||||
String protocolId = receivedMsg.getProtocolId();
|
||||
System.out.println(protocolId.equals(NanoFiles.PROTOCOL_ID));
|
||||
if (protocolId.equals(NanoFiles.PROTOCOL_ID)) {
|
||||
operation = DirMessageOps.OPERATION_PING_OK;
|
||||
System.out.println("Tenemos el protocolo bien");
|
||||
msgToSend.setOperation(DirMessageOps.OPERATION_PING_OK);
|
||||
} else {
|
||||
operation = DirMessageOps.OPERATION_PING_BAD;
|
||||
msgToSend.setOperation(DirMessageOps.OPERATION_PING_BAD);
|
||||
}
|
||||
/*
|
||||
* done: (Boletín MensajesASCII) Construimos un mensaje de respuesta que indique
|
||||
|
||||
Reference in New Issue
Block a user