Skip to content
Snippets Groups Projects
Commit d7bdb7c1 authored by Brutzman, Don's avatar Brutzman, Don
Browse files

improve clarity with comments, rename

parent d45e1465
No related branches found
No related tags found
No related merge requests found
...@@ -46,12 +46,13 @@ public class PduSender ...@@ -46,12 +46,13 @@ public class PduSender
{ {
System.out.println("DisExamples.PduSender started..."); System.out.println("DisExamples.PduSender started...");
try { try {
List<Pdu> generatedPdus = new ArrayList<>(); List<Pdu> generatedPdusList = new ArrayList<>();
// Loop through all the enumerated PDU types, create a PDU for each type, // Loop through all the enumerated PDU types, create a PDU for each type,
// and add that PDU to a list. // add that PDU to generatedPdusList, and send each one
for (PduType pdu : PduType.values()) { for (PduType pdu : PduType.values())
Pdu aPdu = null; {
Pdu aPdu = null; // edu.​nps.​moves.​dis,PDU superclass for all PDUs,
switch (pdu) // using enumeration values from edu.nps.moves.disenum.* switch (pdu) // using enumeration values from edu.nps.moves.disenum.*
{ {
...@@ -140,25 +141,25 @@ public class PduSender ...@@ -140,25 +141,25 @@ public class PduSender
} }
if (aPdu != null) if (aPdu != null)
{ {
generatedPdus.add(aPdu); generatedPdusList.add(aPdu);
} }
} }
// Sort the created PDUs by class name // Sort the created PDUs by class name
Collections.sort(generatedPdus, new ClassNameComparator()); Collections.sort(generatedPdusList, new ClassNameComparator());
// Send the PDUs we created // Send the PDUs we created
InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS);
MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
socket.joinGroup(localMulticastAddress); socket.joinGroup(localMulticastAddress);
for (int idx = 0; idx < generatedPdus.size(); idx++) for (int idx = 0; idx < generatedPdusList.size(); idx++)
{ {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos); DataOutputStream dos = new DataOutputStream(baos);
byte[] buffer; byte[] buffer;
Pdu aPdu = generatedPdus.get(idx); Pdu aPdu = generatedPdusList.get(idx);
aPdu.marshal(dos); aPdu.marshal(dos);
buffer = baos.toByteArray(); buffer = baos.toByteArray();
......
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