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
5d54379e
Commit
5d54379e
authored
5 years ago
by
J. M. Bailey
Browse files
Options
Downloads
Patches
Plain Diff
Improve API a bit
parent
67ef3d6f
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/util/DisThreadedNetIF.java
+22
-9
22 additions, 9 deletions
src/edu/nps/moves/dis7/util/DisThreadedNetIF.java
with
22 additions
and
9 deletions
src/edu/nps/moves/dis7/util/DisThreadedNetIF.java
+
22
−
9
View file @
5d54379e
...
...
@@ -49,20 +49,23 @@ public class DisThreadedNetIF
}
/* *********** class instanciation ************* */
p
rivate
int
DIS_PORT
=
3000
;
p
rivate
String
MCAST_GROUP
=
"225.4.5.6"
;
p
ublic
static
int
DEFAULT_
DIS_PORT
=
3000
;
p
ublic
static
String
DEFAULT_
MCAST_GROUP
=
"225.4.5.6"
;
private
static
final
int
MAX_DIS_PDU_SIZE
=
8192
;
private
int
disPort
;
private
String
mcastGroup
;
private
boolean
killed
=
false
;
private
DisThreadedNetIF
()
{
this
(
3000
,
"225.4.5.6"
);
this
(
DEFAULT_DIS_PORT
,
DEFAULT_MCAST_GROUP
);
}
private
DisThreadedNetIF
(
int
port
,
String
mcastgroup
)
{
DIS_PORT
=
port
;
MCAST_GROUP
=
mcastgroup
;
disPort
=
port
;
mcastGroup
=
mcastgroup
;
init
();
}
...
...
@@ -101,6 +104,16 @@ public class DisThreadedNetIF
});
}
public
int
getDisPort
()
{
return
disPort
;
}
public
String
getMcastGroup
()
{
return
mcastGroup
;
}
public
void
send
(
Pdu
pdu
)
{
pdus2send
.
add
(
pdu
);
...
...
@@ -131,8 +144,8 @@ public class DisThreadedNetIF
DatagramPacket
packet
;
while
(!
killed
)
{
// keep trying on error
try
{
socket
=
new
MulticastSocket
(
DIS_PORT
);
InetAddress
maddr
=
InetAddress
.
getByName
(
MCAST_GROUP
);
socket
=
new
MulticastSocket
(
disPort
);
InetAddress
maddr
=
InetAddress
.
getByName
(
mcastGroup
);
socket
.
setNetworkInterface
(
findIp4Interface
());
socket
.
joinGroup
(
maddr
);
while
(!
killed
)
{
...
...
@@ -162,7 +175,7 @@ public class DisThreadedNetIF
private
final
Runnable
sendThread
=
()
->
{
while
(!
killed
)
{
try
{
InetAddress
maddr
=
InetAddress
.
getByName
(
MCAST_GROUP
);
InetAddress
maddr
=
InetAddress
.
getByName
(
mcastGroup
);
while
(!
killed
)
{
Pdu
pdu
=
pdus2send
.
take
();
...
...
@@ -173,7 +186,7 @@ public class DisThreadedNetIF
pdu
.
marshal
(
dos
);
byte
[]
data
=
baos
.
toByteArray
();
// load byte buffer into packet and send
DatagramPacket
packet
=
new
DatagramPacket
(
data
,
data
.
length
,
maddr
,
DIS_PORT
);
DatagramPacket
packet
=
new
DatagramPacket
(
data
,
data
.
length
,
maddr
,
disPort
);
socket
.
send
(
packet
);
}
}
...
...
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