reduced threads for secondary processing and added threadpool for udp messages. furthermore moved logic around so response concat can be valued

This commit is contained in:
christian
2021-12-07 22:26:19 +01:00
parent e9969f836e
commit e234ce0109
3 changed files with 298 additions and 275 deletions
@@ -89,7 +89,8 @@ public class DiscordHandler extends ListenerAdapter {
private static StanfordCoreNLP stanfordCoreNLP;
private static Datahandler datahandler;
private static StanfordCoreNLP stanfordCoreNLPSentiment;
private static ExecutorService executorService = Executors.newFixedThreadPool(2);
private static ExecutorService executorService = Executors.newFixedThreadPool(1);
private static ExecutorService executorServiceIngame = Executors.newFixedThreadPool(1);
//TODO add python program that edits the java code. python program just adds test if statements on
//variables until the tests pass
@@ -113,14 +114,17 @@ public class DiscordHandler extends ListenerAdapter {
//make sure not to use ports that are already occupied.
for (int i = 0; i < autismbotCount; i++) {
final int j = i;
new Thread(() -> {
ArrayList<Integer> ports = new ArrayList<Integer>();
ports.add(48475);
ports.add(48476);
ports.add(48477);
ports.add(48478);
handleUDPTraffic(ports.get(j), datahandler, stanfordCoreNLP, stanfordCoreNLPSentiment);
}).start();
executorServiceIngame.execute(new Runnable() {
@Override
public void run() {
ArrayList<Integer> ports = new ArrayList<Integer>();
ports.add(48475);
ports.add(48476);
ports.add(48477);
ports.add(48478);
handleUDPTraffic(ports.get(j), datahandler, stanfordCoreNLP, stanfordCoreNLPSentiment);
}
});
}
}
@@ -134,7 +138,8 @@ public class DiscordHandler extends ListenerAdapter {
content = content.replace(member.getId(), "");
}
}
if (username != null && !event.getAuthor().isBot() && !content.isEmpty()) {
if (username != null && !event.getAuthor().isBot() && !content.isEmpty()
&& event.getMessage().getCategory() != null) {
String channelName = event.getMessage().getChannel().getName().toLowerCase();
boolean channelpermissionsDenied = false;
if (channelName.contains("suggestion-box")) {