Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NetworkedGraphicsMV3500
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Savage
NetworkedGraphicsMV3500
Commits
d7bdb7c1
Commit
d7bdb7c1
authored
6 years ago
by
Brutzman, Don
Browse files
Options
Downloads
Patches
Plain Diff
improve clarity with comments, rename
parent
d45e1465
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CourseExamples/src/DisExamples/PduSender.java
+9
-8
9 additions, 8 deletions
CourseExamples/src/DisExamples/PduSender.java
with
9 additions
and
8 deletions
CourseExamples/src/DisExamples/PduSender.java
+
9
−
8
View file @
d7bdb7c1
...
@@ -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
>
generatedPdus
List
=
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
);
generatedPdus
List
.
add
(
aPdu
);
}
}
}
}
// Sort the created PDUs by class name
// Sort the created PDUs by class name
Collections
.
sort
(
generatedPdus
,
new
ClassNameComparator
());
Collections
.
sort
(
generatedPdus
List
,
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
<
generatedPdus
List
.
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
=
generatedPdus
List
.
get
(
idx
);
aPdu
.
marshal
(
dos
);
aPdu
.
marshal
(
dos
);
buffer
=
baos
.
toByteArray
();
buffer
=
baos
.
toByteArray
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment