diff options
author | Anton Tananaev <anton@traccar.org> | 2022-07-11 17:58:35 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-07-11 17:58:35 -0700 |
commit | 767a449904b3d154ded4c5facefc73d7e33650f1 (patch) | |
tree | 712e8c87229d9351cd32eadfce61fd93799f936d /src/main | |
parent | e5fed94589cff4614b248cb3408397febc0b1be7 (diff) | |
download | trackermap-server-767a449904b3d154ded4c5facefc73d7e33650f1.tar.gz trackermap-server-767a449904b3d154ded4c5facefc73d7e33650f1.tar.bz2 trackermap-server-767a449904b3d154ded4c5facefc73d7e33650f1.zip |
Interface for sending multicast
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/broadcast/MulticastBroadcastService.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java index 134bba797..c4ba0e059 100644 --- a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java +++ b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java @@ -161,17 +161,17 @@ public class MulticastBroadcastService implements BroadcastService { @Override public void run() { try (MulticastSocket socket = new MulticastSocket(port)) { - publisherSocket = socket; + socket.setNetworkInterface(networkInterface); socket.joinGroup(group, networkInterface); + publisherSocket = socket; while (!service.isShutdown()) { DatagramPacket packet = new DatagramPacket(receiverBuffer, receiverBuffer.length); socket.receive(packet); String data = new String(packet.getData(), 0, packet.getLength(), StandardCharsets.UTF_8); - LOGGER.info("Broadcast received: {}", data); handleMessage(objectMapper.readValue(data, BroadcastMessage.class)); } - socket.leaveGroup(group, networkInterface); publisherSocket = null; + socket.leaveGroup(group, networkInterface); } catch (IOException e) { throw new RuntimeException(e); } |