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
706cc9ca
Commit
706cc9ca
authored
5 years ago
by
Terry D. Norbraten
Browse files
Options
Downloads
Patches
Plain Diff
update to jdk 14
parent
7017de6a
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
src/edu/nps/moves/dis7/examples/PduSender.java
+15
-7
15 additions, 7 deletions
src/edu/nps/moves/dis7/examples/PduSender.java
with
15 additions
and
7 deletions
src/edu/nps/moves/dis7/examples/PduSender.java
+
15
−
7
View file @
706cc9ca
...
@@ -2,10 +2,13 @@ package edu.nps.moves.dis7.examples;
...
@@ -2,10 +2,13 @@ package edu.nps.moves.dis7.examples;
import
edu.nps.moves.dis7.*
;
import
edu.nps.moves.dis7.*
;
import
edu.nps.moves.dis7.enumerations.DISPDUType
;
import
edu.nps.moves.dis7.enumerations.DISPDUType
;
import
edu.nps.moves.dis7.utilities.DisThreadedNetIF
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.DataOutputStream
;
import
java.io.DataOutputStream
;
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.net.UnknownHostException
;
import
java.net.UnknownHostException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -287,22 +290,27 @@ public class PduSender
...
@@ -287,22 +290,27 @@ public class PduSender
Collections
.
sort
(
generatedPdus
,
new
ClassNameComparator
());
Collections
.
sort
(
generatedPdus
,
new
ClassNameComparator
());
// Send the PDUs we created
// Send the PDUs we created
DatagramPacket
packet
;
InetAddress
localMulticastAddress
=
InetAddress
.
getByName
(
MULTICAST_ADDRESS
);
InetAddress
localMulticastAddress
=
InetAddress
.
getByName
(
MULTICAST_ADDRESS
);
MulticastSocket
socket
=
new
MulticastSocket
(
PORT
);
MulticastSocket
socket
=
new
MulticastSocket
(
PORT
);
socket
.
joinGroup
(
localMulticastAddress
);
InetSocketAddress
group
=
new
InetSocketAddress
(
localMulticastAddress
,
PORT
);
socket
.
joinGroup
(
group
,
DisThreadedNetIF
.
findIp4Interface
());
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
DataOutputStream
dos
=
new
DataOutputStream
(
baos
);
byte
[]
buffer
;
Pdu
aPdu
;
for
(
int
idx
=
0
;
idx
<
generatedPdus
.
size
();
idx
++)
{
for
(
int
idx
=
0
;
idx
<
generatedPdus
.
size
();
idx
++)
{
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
DataOutputStream
dos
=
new
DataOutputStream
(
baos
);
byte
[]
buffer
;
Pdu
aPdu
=
generatedPdus
.
get
(
idx
);
aPdu
=
generatedPdus
.
get
(
idx
);
aPdu
.
marshal
(
dos
);
aPdu
.
marshal
(
dos
);
buffer
=
baos
.
toByteArray
();
buffer
=
baos
.
toByteArray
();
DatagramPacket
packet
=
new
DatagramPacket
(
buffer
,
buffer
.
length
,
localMulticastAddress
,
PORT
);
packet
=
new
DatagramPacket
(
buffer
,
buffer
.
length
,
localMulticastAddress
,
PORT
);
socket
.
send
(
packet
);
socket
.
send
(
packet
);
System
.
out
.
println
(
"Sent PDU of type "
+
aPdu
.
getClass
().
getSimpleName
()
+
" ("
+
aPdu
.
getPduType
().
getValue
()+
")"
);
System
.
out
.
println
(
"Sent PDU of type "
+
aPdu
.
getClass
().
getSimpleName
()
+
" ("
+
aPdu
.
getPduType
().
getValue
()+
")"
);
baos
.
reset
();
}
}
// write the PDUs out to an XML file.
// write the PDUs out to an XML file.
...
@@ -311,7 +319,7 @@ public class PduSender
...
@@ -311,7 +319,7 @@ public class PduSender
//container.marshallToXml("examplePdus.xml");
//container.marshallToXml("examplePdus.xml");
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
System
.
err
.
println
(
e
);
}
}
}
}
...
...
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