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
d2289353
Commit
d2289353
authored
5 years ago
by
Terry D. Norbraten
Browse files
Options
Downloads
Patches
Plain Diff
use new joinGroup
parent
9cb98020
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/edu/nps/moves/dis7/examples/EspduReceiverNIO.java
+9
-5
9 additions, 5 deletions
src/edu/nps/moves/dis7/examples/EspduReceiverNIO.java
src/edu/nps/moves/dis7/examples/EspduSenderNIO.java
+8
-4
8 additions, 4 deletions
src/edu/nps/moves/dis7/examples/EspduSenderNIO.java
with
17 additions
and
9 deletions
src/edu/nps/moves/dis7/examples/EspduReceiverNIO.java
+
9
−
5
View file @
d2289353
...
@@ -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
(
EspduSender
NIO
.
PORT
);
addr
ess
=
InetAddress
.
getByName
(
EspduSender
.
DEFAULT_
MULTICAST_GROUP
);
m
addr
=
InetAddress
.
getByName
(
EspduSender
NIO
.
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
)
{
...
...
This diff is collapsed.
Click to expand it.
src/edu/nps/moves/dis7/examples/EspduSenderNIO.java
+
8
−
4
View file @
d2289353
...
@@ -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
,
addr
ess
,
PORT
);
DatagramPacket
packet
=
new
DatagramPacket
(
data
,
data
.
length
,
m
addr
,
PORT
);
while
(
true
)
{
while
(
true
)
{
for
(
int
idx
=
0
;
idx
<
100
;
idx
++)
{
for
(
int
idx
=
0
;
idx
<
100
;
idx
++)
{
...
...
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