|
@@ -154,11 +154,14 @@ public class UdpServerApplication extends Application implements UdpServer.Messa
|
|
|
@Override
|
|
|
public void processMessage(String message) {
|
|
|
System.out.println("Server received: " + message);
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
if (message.endsWith("#END#")) {
|
|
|
message = message.substring(0, message.length() - "#END#".length() - 1);
|
|
|
+ json = JSONObject.parseObject(message);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ json = parseString2JSON(message);
|
|
|
}
|
|
|
-// JSONObject json = parseString2JSON(message);
|
|
|
- JSONObject json = JSONObject.parseObject(message);
|
|
|
System.out.println("json string: " + json.toJSONString());
|
|
|
if (json.containsKey("request")){
|
|
|
return;
|
|
@@ -179,8 +182,8 @@ public class UdpServerApplication extends Application implements UdpServer.Messa
|
|
|
// });
|
|
|
|
|
|
|
|
|
- boolean exists = data.stream().anyMatch(p -> p != null && p.getIpAddress() != null && p.getIpAddress().equals(json.getString("IPaddress")));
|
|
|
- System.out.println("exists ===> " + exists);
|
|
|
+ JSONObject finalJson = json;
|
|
|
+ boolean exists = data.stream().anyMatch(p -> p != null && p.getIpAddress() != null && p.getIpAddress().equals(finalJson.getString("IPaddress")));
|
|
|
if (!exists) {
|
|
|
Platform.runLater(() -> {
|
|
|
data.add(udpMessage);
|