Skip to content
Snippets Groups Projects
Commit d2289353 authored by Terry D. Norbraten's avatar Terry D. Norbraten
Browse files

use new joinGroup

parent 9cb98020
No related branches found
No related tags found
No related merge requests found
...@@ -5,10 +5,12 @@ ...@@ -5,10 +5,12 @@
package edu.nps.moves.dis7.examples; package edu.nps.moves.dis7.examples;
import edu.nps.moves.dis7.Pdu; import edu.nps.moves.dis7.Pdu;
import edu.nps.moves.dis7.utilities.DisThreadedNetIF;
import edu.nps.moves.dis7.utilities.PduFactory; import edu.nps.moves.dis7.utilities.PduFactory;
import java.io.IOException; import java.io.IOException;
import java.net.DatagramPacket; import java.net.DatagramPacket;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.MulticastSocket; import java.net.MulticastSocket;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
...@@ -31,7 +33,8 @@ public class EspduReceiverNIO ...@@ -31,7 +33,8 @@ public class EspduReceiverNIO
public static void main(String args[]) public static void main(String args[])
{ {
MulticastSocket socket; MulticastSocket socket;
InetAddress address; InetAddress maddr;
InetSocketAddress group;
PduFactory pduFactory = new PduFactory(); PduFactory pduFactory = new PduFactory();
byte buffer[] = new byte[MAX_PDU_SIZE]; byte buffer[] = new byte[MAX_PDU_SIZE];
DatagramPacket packet = new DatagramPacket(buffer, buffer.length); DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
...@@ -39,11 +42,12 @@ public class EspduReceiverNIO ...@@ -39,11 +42,12 @@ public class EspduReceiverNIO
Pdu pdu; Pdu pdu;
try { try {
// Specify the socket to receive data // Specify the socket to receive data
socket = new MulticastSocket(EspduSender.DIS_DESTINATION_PORT); socket = new MulticastSocket(EspduSenderNIO.PORT);
address = InetAddress.getByName(EspduSender.DEFAULT_MULTICAST_GROUP); maddr = InetAddress.getByName(EspduSenderNIO.MULTICAST_GROUP);
// TODO fix deprecation by adding NetworkInterface (hopefully DisThreadedNetworkInterface) group = new InetSocketAddress(maddr, EspduSenderNIO.PORT);
socket.joinGroup(address); socket.joinGroup(group, DisThreadedNetIF.findIp4Interface());
// Loop infinitely, receiving datagrams // Loop infinitely, receiving datagrams
while (true) { while (true) {
......
...@@ -8,8 +8,10 @@ import edu.nps.moves.dis7.EntityID; ...@@ -8,8 +8,10 @@ import edu.nps.moves.dis7.EntityID;
import edu.nps.moves.dis7.EntityStatePdu; import edu.nps.moves.dis7.EntityStatePdu;
import edu.nps.moves.dis7.EulerAngles; import edu.nps.moves.dis7.EulerAngles;
import edu.nps.moves.dis7.Vector3Double; import edu.nps.moves.dis7.Vector3Double;
import edu.nps.moves.dis7.utilities.DisThreadedNetIF;
import java.net.DatagramPacket; import java.net.DatagramPacket;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.MulticastSocket; import java.net.MulticastSocket;
/** /**
...@@ -35,7 +37,8 @@ public class EspduSenderNIO ...@@ -35,7 +37,8 @@ public class EspduSenderNIO
public static void main(String args[]) public static void main(String args[])
{ {
MulticastSocket socket; MulticastSocket socket;
InetAddress address; InetAddress maddr;
InetSocketAddress group;
EntityStatePdu espdu = new EntityStatePdu(); EntityStatePdu espdu = new EntityStatePdu();
espdu.setExerciseID((byte) 0); espdu.setExerciseID((byte) 0);
...@@ -50,14 +53,15 @@ public class EspduSenderNIO ...@@ -50,14 +53,15 @@ public class EspduSenderNIO
try { try {
socket = new MulticastSocket(PORT); socket = new MulticastSocket(PORT);
address = InetAddress.getByName(MULTICAST_GROUP); maddr = InetAddress.getByName(MULTICAST_GROUP);
socket.joinGroup(address); group = new InetSocketAddress(maddr, PORT);
socket.joinGroup(group, DisThreadedNetIF.findIp4Interface());
Vector3Double location; Vector3Double location;
EulerAngles orientation; EulerAngles orientation;
float psi; float psi;
byte[] data = new byte[144]; byte[] data = new byte[144];
DatagramPacket packet = new DatagramPacket(data, data.length, address, PORT); DatagramPacket packet = new DatagramPacket(data, data.length, maddr, PORT);
while (true) { while (true) {
for (int idx = 0; idx < 100; idx++) { for (int idx = 0; idx < 100; idx++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment