LANServerListener: don't use deprecated methods

This commit is contained in:
Bixilon 2020-12-17 20:49:43 +01:00
parent 250a005c3a
commit dd03a77da8
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -21,9 +21,7 @@ import de.bixilon.minosoft.util.ServerAddress;
import de.bixilon.minosoft.util.Util; import de.bixilon.minosoft.util.Util;
import javafx.application.Platform; import javafx.application.Platform;
import java.net.DatagramPacket; import java.net.*;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashSet; import java.util.HashSet;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
@ -41,7 +39,7 @@ public class LANServerListener {
new Thread(() -> { new Thread(() -> {
try { try {
MulticastSocket socket = new MulticastSocket(ProtocolDefinition.LAN_SERVER_BROADCAST_PORT); MulticastSocket socket = new MulticastSocket(ProtocolDefinition.LAN_SERVER_BROADCAST_PORT);
socket.joinGroup(ProtocolDefinition.LAN_SERVER_BROADCAST_ADDRESS); // ToDo: do not use deprecated methods socket.joinGroup(new InetSocketAddress(ProtocolDefinition.LAN_SERVER_BROADCAST_ADDRESS, ProtocolDefinition.LAN_SERVER_BROADCAST_PORT), NetworkInterface.getByInetAddress(ProtocolDefinition.LAN_SERVER_BROADCAST_ADDRESS));
byte[] buf = new byte[256]; // this should be enough, if the packet is longer, it is probably invalid byte[] buf = new byte[256]; // this should be enough, if the packet is longer, it is probably invalid
latch.countDown(); latch.countDown();
while (true) { while (true) {