From 5f4d803ef24ab24ea406a3bef6aca7e51d7e1bce Mon Sep 17 00:00:00 2001 From: christian Date: Tue, 6 Apr 2021 23:58:20 +0200 Subject: [PATCH] further updates --- .../main/java/FunctionLayer/Datahandler.java | 38 +++++-------------- .../PresentationLayer/DiscordHandler.java | 3 -- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java b/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java index 59ae6679..490bedb8 100644 --- a/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java +++ b/ArtificialAutism/src/main/java/FunctionLayer/Datahandler.java @@ -770,6 +770,7 @@ public class Datahandler { public void update_autismo_socket_msg() { try { try (DatagramSocket serverSocket = new DatagramSocket(48477)) { + try (DatagramSocket serverSocket1 = new DatagramSocket(48478)) { byte[] receiveData = new byte[4096]; InetAddress IPAddress = InetAddress.getByName("144.76.218.19"); DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); @@ -781,33 +782,16 @@ public class Datahandler { byte[] sendData = getResponseMsg.getBytes("UTF-8"); DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 48477); serverSocket.send(sendPacket); - } - } catch (CustomError ex) { - Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex); - } - } catch (SocketException ex) { - Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex); - } catch (UnsupportedEncodingException ex) { - Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex); - } catch (IOException ex) { - Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex); - } - } - - public void update_autismo_socket_msg1() { - try { - try (DatagramSocket serverSocket = new DatagramSocket(48478)) { - byte[] receiveData = new byte[4096]; - InetAddress IPAddress = InetAddress.getByName("144.76.218.19"); - DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); - while (true) { - serverSocket.receive(receivePacket); - String sentence = new String(receivePacket.getData(), 0, receivePacket.getLength()); + + receivePacket = new DatagramPacket(receiveData, receiveData.length); + serverSocket1.receive(receivePacket); + sentence = new String(receivePacket.getData(), 0, receivePacket.getLength()); sentence = sentence.replace("clientmessage:", ""); - String getResponseMsg = getResponseMsg(sentence); - byte[] sendData = getResponseMsg.getBytes("UTF-8"); - DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 48478); - serverSocket.send(sendPacket); + getResponseMsg = getResponseMsg(sentence); + sendData = getResponseMsg.getBytes("UTF-8"); + sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 48478); + serverSocket1.send(sendPacket); + } } } catch (CustomError ex) { Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex); @@ -832,8 +816,6 @@ public class Datahandler { annotationsT.add(ann); } } - - public static ConcurrentMap getMultipleCoreDocumentsWaySuggestion(Collection str, StanfordCoreNLP localNLP) { AnnotationCollector annCollector = new AnnotationCollector(); diff --git a/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java b/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java index 25108e1e..23d87a64 100644 --- a/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java +++ b/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java @@ -61,9 +61,6 @@ public class DiscordHandler { new Thread(() -> { Datahandler.instance.update_autismo_socket_msg(); }).start(); - new Thread(() -> { - Datahandler.instance.update_autismo_socket_msg1(); - }).start(); gateway.on(MessageCreateEvent.class).subscribe(event -> { if (!FunctionLayer.DoStuff.isOccupied()) { FunctionLayer.DoStuff.doStuff(event, usernameBot);