From d5b4820c79f1769069909a373e49a6eb5e519da1 Mon Sep 17 00:00:00 2001 From: Thibaut Valentin Date: Fri, 22 Mar 2024 20:43:39 +0100 Subject: [PATCH] feat: send record v2 --- .../fr/titionfire/ffsaf/ws/FileSocket.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/main/java/fr/titionfire/ffsaf/ws/FileSocket.java b/src/main/java/fr/titionfire/ffsaf/ws/FileSocket.java index 96d61aa..283a09b 100644 --- a/src/main/java/fr/titionfire/ffsaf/ws/FileSocket.java +++ b/src/main/java/fr/titionfire/ffsaf/ws/FileSocket.java @@ -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()); } }); }