feat: send record v2

This commit is contained in:
Thibaut Valentin 2024-03-22 20:43:39 +01:00
parent 3c0f1b01d6
commit d5b4820c79

View File

@ -51,19 +51,13 @@ public class FileSocket {
fileRecv.fos = new FileOutputStream(fileRecv.file, false);
logger.info("Start reception of file: " + fileRecv.file.getAbsolutePath());
} else {
// session.close(new CloseReason(CloseReason.CloseCodes.VIOLATED_POLICY, "File not found"));
session.close(new CloseReason(CloseReason.CloseCodes.VIOLATED_POLICY, "File not found"));
}
} catch (IOException e) {
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
logger.error(errors.toString());
}
session.getAsyncRemote().sendText("ok", result -> {
if (result.getException() != null) {
System.out.println("Unable to send message: " + result.getException());
}
});
}
@OnClose
@ -137,7 +131,7 @@ public class FileSocket {
if (check_sum != data[0]) {
fileRecv.session.getAsyncRemote().sendText("Error: Checksum error", result -> {
if (result.getException() != null) {
System.out.println("Unable to send message: " + result.getException());
logger.error("Unable to send message: " + result.getException());
}
});
return;
@ -151,15 +145,9 @@ public class FileSocket {
logger.error(errors.toString());
}
try {
Thread.sleep(1);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
fileRecv.session.getAsyncRemote().sendText("ok", result -> {
if (result.getException() != null) {
System.out.println("Unable to send message: " + result.getException());
logger.error("Unable to send message: " + result.getException());
}
});
}