updated datagram sockets, had managed to fuck up the port

This commit is contained in:
jenz 2022-11-19 21:57:25 +01:00
parent eb7ed76d2e
commit 10eedf6529
3 changed files with 58 additions and 55 deletions

View File

@ -93,7 +93,7 @@ public class DataMapper {
ResultSet resultSet = l_pStatement.executeQuery();
if (resultSet.next()) {
int count = resultSet.getInt(1);
if (count > 35000) {
if (count > 13000) {
//System.out.println("cleaning strings: " + l_sSQL);
l_pStatement = l_cCon.prepareStatement(l_sSQL);
l_pStatement.executeUpdate();

View File

@ -8,16 +8,14 @@ import java.io.UnsupportedEncodingException;
import java.net.*;
public class ThreadClient {
public ThreadClient(int port, Datahandler datahandler, StanfordCoreNLP stanfordCoreNLP, StanfordCoreNLP stanfordCoreNLPSentiment) {
String hostIP = new settings().getHostIP();
if (port == new settings().getHostport() || port == new settings().getHostport2()) {
hostIP = new settings().getHostIP2();
}
try {
InetAddress ipAddress = InetAddress.getByName(hostIP);//used ip'
try (DatagramSocket serverSocket = new DatagramSocket()) {
InetAddress ipAddress = InetAddress.getByName(hostIP);//used ip's
try (DatagramSocket serverSocket = new DatagramSocket(port)) {
while (true) {
receiveAndSendPacket(serverSocket, ipAddress, port, datahandler, stanfordCoreNLP, stanfordCoreNLPSentiment);
}
@ -30,7 +28,7 @@ public class ThreadClient {
e.printStackTrace();
}
}
}
private static void receiveAndSendPacket(DatagramSocket serverSocket, InetAddress ipAddress, int port,
Datahandler datahandler, StanfordCoreNLP stanfordCoreNLP, StanfordCoreNLP stanfordCoreNLPSentiment) throws
@ -42,7 +40,6 @@ public class ThreadClient {
} catch (IOException e) {
e.printStackTrace();
}
new Thread(() -> {
String sentence = new String(receivePacket.getData(), 0,
receivePacket.getLength());
sentence = sentence.replace("clientmessage:", "");
@ -75,6 +72,5 @@ public class ThreadClient {
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
}

View File

@ -44,14 +44,18 @@ public class DiscordHandler extends ListenerAdapter {
stanfordCoreNLPSentiment = datahandler.shiftReduceParserInitiate();
System.out.println("FINISHED ALL ANNOTATIONS");
System.out.println("updatedstring cache");
String strF = datahandler.trimString("abcdef");
datahandler.getResponseFutures(strF, stanfordCoreNLP, stanfordCoreNLPSentiment);
String token = new settings().getDiscordToken();
try {
JDABuilder.createLight(token, GatewayIntent.GUILD_MESSAGES, GatewayIntent.DIRECT_MESSAGES)
.addEventListeners(new DiscordHandler())
.setActivity(Activity.playing("Being the autism bot"))
.build();
} catch (LoginException e) {
throw new RuntimeException(e);
}
ArrayList<Integer> ports = new ArrayList<Integer>();
ports.add(48475);
@ -59,10 +63,13 @@ public class DiscordHandler extends ListenerAdapter {
ports.add(48477);
ports.add(48478);
for (Integer port : ports) {
new Thread(() -> {
new ThreadClient(port, datahandler, stanfordCoreNLP, stanfordCoreNLPSentiment);
}).start();
}
}
@Override
public void onMessageReceived(MessageReceivedEvent event) {
String content = event.getMessage().getContentRaw();